QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#562156#7744. Elevatorchiliplus#WA 36ms4396kbC++141.8kb2024-09-13 15:22:182024-09-13 15:22:19

Judging History

你现在查看的是最新测评结果

  • [2024-09-13 15:22:19]
  • 评测
  • 测评结果:WA
  • 用时:36ms
  • 内存:4396kb
  • [2024-09-13 15:22:18]
  • 提交

answer

#include <bits/stdc++.h>

using Cargo = std :: pair<int, int>;

std :: vector<Cargo> w1, w2;

int n;
long long k;

void init() {
    w1.clear(), w2.clear();
}

std :: vector<Cargo> combine( std :: vector<Cargo> &cgo, const long long &siz ) {
    std :: sort( cgo.begin(), cgo.end(), std :: greater<Cargo> () );

    long long curSiz = 0;
    int l = cgo.size(), curWei = 0;
    std :: vector<Cargo> ret;

    auto add_new = [&] ( const int &f, const int &c ) -> void {
        if( c == 0 ) return ;
        if( ret.size() && ret.back().first == f )
            ret.back().second ++;
        else ret.emplace_back( f, c );
    };

    for( int i = 0 ; i < l ; i ++ ) {
        int f = cgo[i].first, c = cgo[i].second;
        if( curSiz > 0 ) {
            if( curSiz + c < siz ) {
                curSiz += c; continue;
            }
            add_new( curWei, 1 );
            c -= siz - curSiz;
            curSiz = curWei = 0;
        }
        add_new( f, c / siz );
        if( c % siz )
            curSiz = c % siz, curWei = f;
    }
    if( curSiz ) add_new( curWei, 1 );
    return ret;
}

void solve() {
    long long totWei = 0;
    std :: cin >> n >> k, init();
    for( int i = 1 ; i <= n ; i ++ ) {
        int c, w, f;
        std :: cin >> c >> w >> f;
        ( w == 1 ? w1 : w2 ).emplace_back( f, c );
        totWei += w * c;
    }
    std :: vector<Cargo> &&tmp = combine( w1, 2 );
    for( const auto &c : tmp ) w2.push_back( c );
    std :: vector<Cargo> &&res = combine( w2, k >> 1 );
    long long ans = 0;
    for( const auto &c : res )
        ans += 1ll * c.first * c.second;
    std :: cout << ans << std :: endl;
}

int main() {
    std :: ios :: sync_with_stdio( false );
    int t; std :: cin >> t;
    while( t -- ) solve(); 
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3576kb

input:

2
4 6
1 1 8
7 2 5
1 1 7
3 2 6
8 1200000
100000 1 100000
100000 1 12345
100000 2 100000
100000 2 12345
100000 1 100000
100000 1 12345
100000 2 100000
100000 2 12345

output:

24
100000

result:

ok 2 lines

Test #2:

score: -100
Wrong Answer
time: 36ms
memory: 4396kb

input:

5501
8 104
5 2 3
6 2 4
5 2 3
6 2 9
8 2 4
2 1 3
7 2 4
8 2 8
1 290
3 1 1
12 12
6 1 2
1 2 2
1 1 2
1 2 4
6 1 1
1 2 5
6 1 4
4 1 4
6 2 4
6 2 5
4 2 5
4 1 4
5 334
1 1 4
1 2 3
4 2 1
5 1 1
2 1 2
13 218
5 2 3
5 1 4
1 2 1
1 2 5
3 2 2
1 1 3
4 2 2
1 2 5
2 2 1
2 1 5
3 2 1
5 2 1
1 1 4
10 260
7 2 1
5 1 1
5 2 4
6 1 6...

output:

9
1
21
4
5
7
1
3
9
6
1
10
4
9
17
5
4
1
8
5
5
7
1
3
23
6
3
3
2
2
2
3
8
1
5
6
9
11
120
7
10
2
7
7
8
6
5
5
1
7
3
5
10
7
7
10
8
1
4
2
3
9
1
5
2
9
1
6
7
7
6
10
18
8
10
4
10
9
2
8
3
5
9
3
6
5
3
2
6
1
3
2
2
1
6
9
6
3
4
8
9
9
2
6
1
2
6
7
5
2
5
21
8
1
2
3
4
9
3
4
6
5
9
6
1
7
3
7
3
2
2
8
7
3
5
9
7
10
7
3
2
4
...

result:

wrong answer 3rd lines differ - expected: '23', found: '21'