QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#611283#8586. PartyWansur0 0ms3488kbC++231.8kb2024-10-04 20:12:492024-10-04 20:12:50

Judging History

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

  • [2024-10-04 20:12:50]
  • 评测
  • 测评结果:0
  • 用时:0ms
  • 内存:3488kb
  • [2024-10-04 20:12:49]
  • 提交

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();
                }
            }
            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();
    }
}

詳細信息

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3488kb

input:

5
3 2 -1 4 5

output:

0
0
0
0
0

result:

wrong answer 1st lines differ - expected: '12', found: '0'

Subtask #2:

score: 0
Skipped

Dependency #1:

0%

Subtask #3:

score: 0
Skipped

Dependency #1:

0%