QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#611293#8588. Amusement ParkWansur7 32ms8348kbC++231.8kb2024-10-04 20:13:402024-10-04 20:13:43

Judging History

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

  • [2024-10-04 20:13:43]
  • 评测
  • 测评结果:7
  • 用时:32ms
  • 内存:8348kb
  • [2024-10-04 20:13:40]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
const int maxn = 1e6 + 12;

bool del[maxn];
int a[maxn];
int n, m;

void solve(){
    int Q;
    cin >> Q;
    int cnt = 0;
    queue<int> p, q;
    while(Q--){
        ll tp, x, y;
        cin >> tp >> x;
        if(tp == 1){
            cnt++;
            cin >> y;
            a[cnt] = x;
            if(y) p.push(cnt);
            else q.push(cnt);
        }
        else if(tp == 2){
            del[x] = 1;
        }
        else{
            vector<pair<int, int>> ans;
            while(x > 0 && (p.size() || q.size())){
                if(p.size() && del[p.front()]){
                    p.pop();
                    continue;
                }
                if(q.size() && del[q.front()]){
                    q.pop();
                    continue;
                }
                if(!q.size() || p.size() && (p.front() < q.front() || a[q.front()] > x)){
                    ll val = min(x, (ll) a[p.front()]);
                    ans.push_back({p.front(), val});
                    x -= val;
                    a[p.front()] -= val;
                    if(a[p.front()] == 0){
                        p.pop();
                    }
                }
                else if(x >= a[q.front()]){
                    x -= a[q.front()];
                    ans.push_back({q.front(), a[q.front()]});
                    q.pop();
                }
                else break;
            }
            cout << ans.size() << '\n';
            for(auto [x, y]:ans){
                cout << x << ' ' << y << '\n';
            }
        }
    }
}

int32_t main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int t = 1;
    // cin >> t;
    while(t--){
        solve();
    }
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 12
Accepted
time: 0ms
memory: 3788kb

input:

7
1 2 0
1 6 0
1 6 1
3 5
2 2
1 3 0
3 123456789012

output:

2
1 2
3 3
2
3 3
4 3

result:

ok 6 lines

Test #2:

score: 12
Accepted
time: 0ms
memory: 3624kb

input:

5
1 1 0
1 1 0
1 1 0
3 2
1 1 0

output:

2
1 1
2 1

result:

ok 3 lines

Test #3:

score: 12
Accepted
time: 0ms
memory: 3588kb

input:

4
1 19 1
3 10
3 10
3 10

output:

1
1 10
1
1 9
0

result:

ok 5 lines

Test #4:

score: 0
Wrong Answer
time: 1ms
memory: 3564kb

input:

1000
1 103259 0
1 128742 0
1 58949 0
1 147463 1
1 122606 0
3 182905
1 132106 0
1 40502 1
1 123736 1
1 4543 1
1 163109 1
1 41758 0
1 176061 0
3 178835
3 184068
3 195391
1 86319 0
1 80890 1
1 121580 0
1 52574 0
1 184660 0
1 183865 0
1 160678 0
1 7243 1
1 4283 1
1 160664 0
1 161622 0
1 193227 0
1 41195...

output:

2
1 103259
4 79646
2
2 128742
4 50093
4
3 58949
4 17724
7 40502
8 66893
4
5 122606
8 56843
9 4543
10 11399
2
6 132106
10 16915
2
10 134795
14 33793
6
11 41758
14 47097
20 7243
21 4283
25 41195
26 24625
2
12 176061
26 12646
2
13 86319
26 38701
2
15 121580
26 31547
6
16 52574
26 43303
27 1187
28 5816
...

result:

wrong answer 1st lines differ - expected: '3', found: '2'

Subtask #2:

score: 7
Accepted

Test #11:

score: 7
Accepted
time: 27ms
memory: 8348kb

input:

200000
1 1 0
1 1 0
1 1 0
1 1 0
1 1 0
1 1 0
1 1 0
1 1 0
1 1 0
1 1 0
1 1 0
1 1 0
1 1 0
1 1 0
1 1 0
1 1 0
1 1 0
1 1 0
1 1 0
1 1 0
1 1 0
1 1 0
1 1 0
1 1 0
1 1 0
1 1 0
1 1 0
1 1 0
1 1 0
1 1 0
1 1 0
1 1 0
1 1 0
1 1 0
1 1 0
1 1 0
1 1 0
1 1 0
1 1 0
1 1 0
1 1 0
1 1 0
1 1 0
1 1 0
1 1 0
1 1 0
1 1 0
1 1 0
1 1 0...

output:

199999
1 1
2 1
3 1
4 1
5 1
6 1
7 1
8 1
9 1
10 1
11 1
12 1
13 1
14 1
15 1
16 1
17 1
18 1
19 1
20 1
21 1
22 1
23 1
24 1
25 1
26 1
27 1
28 1
29 1
30 1
31 1
32 1
33 1
34 1
35 1
36 1
37 1
38 1
39 1
40 1
41 1
42 1
43 1
44 1
45 1
46 1
47 1
48 1
49 1
50 1
51 1
52 1
53 1
54 1
55 1
56 1
57 1
58 1
59 1
60 1
61...

result:

ok 200000 lines

Test #12:

score: 7
Accepted
time: 26ms
memory: 4820kb

input:

199999
1 1 0
1 1 0
1 1 0
1 1 0
1 1 0
1 1 0
1 1 0
1 1 0
1 1 0
1 1 0
1 1 0
1 1 0
1 1 0
1 1 0
1 1 0
1 1 0
1 1 0
1 1 0
1 1 0
1 1 0
3 10
1 1 0
1 1 0
1 1 0
3 5
1 1 0
3 4
1 1 0
1 1 0
1 1 0
1 1 0
1 1 0
1 1 0
1 1 0
1 1 0
3 2
1 1 0
1 1 0
1 1 0
1 1 0
3 1
1 1 0
1 1 0
1 1 0
1 1 0
3 5
1 1 0
1 1 0
1 1 0
1 1 0
1 1 ...

output:

10
1 1
2 1
3 1
4 1
5 1
6 1
7 1
8 1
9 1
10 1
5
11 1
12 1
13 1
14 1
15 1
4
16 1
17 1
18 1
19 1
2
20 1
21 1
1
22 1
5
23 1
24 1
25 1
26 1
27 1
5
28 1
29 1
30 1
31 1
32 1
6
33 1
34 1
35 1
36 1
37 1
38 1
4
39 1
40 1
41 1
42 1
7
43 1
44 1
45 1
46 1
47 1
48 1
49 1
4
50 1
51 1
52 1
53 1
7
54 1
55 1
56 1
57 1...

result:

ok 117470 lines

Test #13:

score: 7
Accepted
time: 24ms
memory: 4628kb

input:

199998
1 1 0
1 1 0
1 1 0
1 1 0
1 1 0
1 1 0
1 1 0
1 1 0
1 1 0
1 1 0
1 1 0
1 1 0
1 1 0
1 1 0
1 1 0
1 1 0
1 1 0
1 1 0
1 1 0
1 1 0
1 1 0
1 1 0
1 1 0
1 1 0
1 1 0
1 1 0
1 1 0
1 1 0
1 1 0
1 1 0
1 1 0
1 1 0
1 1 0
1 1 0
1 1 0
1 1 0
1 1 0
1 1 0
1 1 0
1 1 0
1 1 0
1 1 0
1 1 0
1 1 0
1 1 0
1 1 0
1 1 0
1 1 0
1 1 0...

output:

538
1 1
2 1
3 1
4 1
5 1
6 1
7 1
8 1
9 1
10 1
11 1
12 1
13 1
14 1
15 1
16 1
17 1
18 1
19 1
20 1
21 1
22 1
23 1
24 1
25 1
26 1
27 1
28 1
29 1
30 1
31 1
32 1
33 1
34 1
35 1
36 1
37 1
38 1
39 1
40 1
41 1
42 1
43 1
44 1
45 1
46 1
47 1
48 1
49 1
50 1
51 1
52 1
53 1
54 1
55 1
56 1
57 1
58 1
59 1
60 1
61 1
...

result:

ok 104375 lines

Subtask #3:

score: 0
Wrong Answer

Dependency #2:

100%
Accepted

Test #14:

score: 20
Accepted
time: 32ms
memory: 4328kb

input:

200000
1 4 0
1 10 0
1 9 0
1 9 0
1 1 0
1 8 0
3 707714796138
1 6 0
1 1 0
1 8 0
1 5 0
1 1 0
1 3 0
1 3 0
1 8 0
1 2 0
1 2 0
1 1 0
1 3 0
1 3 0
1 10 0
1 3 0
1 2 0
1 4 0
1 4 0
1 6 0
1 5 0
1 1 0
1 8 0
1 7 0
1 1 0
1 4 0
1 9 0
1 6 0
1 7 0
1 5 0
1 4 0
1 3 0
1 7 0
1 1 0
1 5 0
1 1 0
1 10 0
1 3 0
1 6 0
3 443456506...

output:

6
1 4
2 10
3 9
4 9
5 1
6 8
38
7 6
8 1
9 8
10 5
11 1
12 3
13 3
14 8
15 2
16 2
17 1
18 3
19 3
20 10
21 3
22 2
23 4
24 4
25 6
26 5
27 1
28 8
29 7
30 1
31 4
32 9
33 6
34 7
35 5
36 4
37 3
38 7
39 1
40 5
41 1
42 10
43 3
44 6
113
45 8
46 1
47 7
48 8
49 1
50 9
51 10
52 9
53 3
54 1
55 9
56 8
57 6
58 6
59 7
6...

result:

ok 200000 lines

Test #15:

score: 0
Wrong Answer
time: 19ms
memory: 6176kb

input:

200000
1 3 0
1 2 0
1 8 0
1 8 0
1 4 0
1 3 0
1 3 0
1 3 0
1 6 0
1 8 0
1 1 0
1 5 0
1 6 0
1 5 0
1 10 0
1 2 0
1 6 0
1 9 0
1 6 0
1 10 0
1 3 0
1 8 0
1 5 0
1 2 0
1 4 0
1 7 0
1 6 0
1 1 0
1 7 0
1 9 0
1 8 0
1 2 0
1 2 0
1 7 0
1 4 0
1 7 0
1 10 0
1 3 0
1 3 0
1 10 0
1 1 0
1 1 0
1 7 0
1 5 0
1 8 0
1 6 0
1 2 0
1 8 0
1...

output:

446
1 3
2 2
3 8
4 8
5 4
6 3
7 3
8 3
9 6
10 8
11 1
12 5
13 6
14 5
15 10
16 2
17 6
18 9
19 6
20 10
21 3
22 8
23 5
24 2
25 4
26 7
27 6
28 1
29 7
30 9
31 8
32 2
33 2
34 7
35 4
36 7
37 10
38 3
39 3
40 10
41 1
42 1
43 7
44 5
45 8
46 6
47 2
48 8
49 3
50 8
51 1
52 4
53 9
54 9
55 1
56 2
57 8
58 7
59 1
60 2
6...

result:

wrong answer 908th lines differ - expected: '135', found: '134'

Subtask #4:

score: 0
Skipped

Dependency #3:

0%

Subtask #5:

score: 0
Skipped

Dependency #4:

0%

Subtask #6:

score: 0
Skipped

Dependency #1:

0%