답안 #816549

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
816549 2023-08-09T05:38:30 Z 이동현(#10127) Ants and Sugar (JOI22_sugar) C++17
6 / 100
4000 ms 1132 KB
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#define int long long
using namespace std;

signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    int n, L;
    cin >> n >> L;
    vector<array<int, 2>> A, B, as, bs;
    for(int rep = 0; rep < n; ++rep){
        int t, x, a;
        cin >> t >> x >> a;
        if(t == 1) A.push_back({x, a});
        else B.push_back({x, a});

        sort(A.begin(), A.end());
        sort(B.begin(), B.end());
        as = A, bs = B;

        int ap = 0, bp = 0, ans = 0;

        while(ap < (int)A.size() && bp < (int)B.size()){
            if(A[ap][0] + L < B[bp][0] || !A[ap][1]){
                ++ap;
            }
            else if(B[bp][0] + L < A[ap][0] || !B[bp][1]){
                ++bp;
            }
            else{
                int mn = min(A[ap][1], B[bp][1]);
                ans += mn;
                A[ap][1] -= mn, B[bp][1] -= mn;
            }
        }

        cout << ans << '\n';

        swap(as, A), swap(bs, B);
    }
    
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 78 ms 404 KB Output is correct
7 Correct 51 ms 376 KB Output is correct
8 Correct 13 ms 340 KB Output is correct
9 Correct 12 ms 340 KB Output is correct
10 Correct 144 ms 496 KB Output is correct
11 Correct 167 ms 452 KB Output is correct
12 Correct 155 ms 436 KB Output is correct
13 Correct 163 ms 532 KB Output is correct
14 Correct 217 ms 480 KB Output is correct
15 Correct 224 ms 508 KB Output is correct
16 Correct 204 ms 504 KB Output is correct
17 Correct 211 ms 528 KB Output is correct
18 Correct 212 ms 472 KB Output is correct
19 Correct 144 ms 504 KB Output is correct
20 Correct 213 ms 488 KB Output is correct
21 Correct 154 ms 572 KB Output is correct
22 Correct 217 ms 440 KB Output is correct
23 Correct 159 ms 504 KB Output is correct
24 Correct 217 ms 404 KB Output is correct
25 Correct 158 ms 444 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Execution timed out 4059 ms 1132 KB Time limit exceeded
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Execution timed out 4046 ms 992 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 78 ms 404 KB Output is correct
7 Correct 51 ms 376 KB Output is correct
8 Correct 13 ms 340 KB Output is correct
9 Correct 12 ms 340 KB Output is correct
10 Correct 144 ms 496 KB Output is correct
11 Correct 167 ms 452 KB Output is correct
12 Correct 155 ms 436 KB Output is correct
13 Correct 163 ms 532 KB Output is correct
14 Correct 217 ms 480 KB Output is correct
15 Correct 224 ms 508 KB Output is correct
16 Correct 204 ms 504 KB Output is correct
17 Correct 211 ms 528 KB Output is correct
18 Correct 212 ms 472 KB Output is correct
19 Correct 144 ms 504 KB Output is correct
20 Correct 213 ms 488 KB Output is correct
21 Correct 154 ms 572 KB Output is correct
22 Correct 217 ms 440 KB Output is correct
23 Correct 159 ms 504 KB Output is correct
24 Correct 217 ms 404 KB Output is correct
25 Correct 158 ms 444 KB Output is correct
26 Correct 0 ms 212 KB Output is correct
27 Correct 0 ms 212 KB Output is correct
28 Correct 0 ms 212 KB Output is correct
29 Execution timed out 4059 ms 1132 KB Time limit exceeded
30 Halted 0 ms 0 KB -