QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#611283 | #8586. Party | Wansur | 0 | 0ms | 3488kb | C++23 | 1.8kb | 2024-10-04 20:12:49 | 2024-10-04 20:12:50 |
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%