# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
615304 | 2022-07-31T08:21:42 Z | 조영욱(#8494) | Ants and Sugar (JOI22_sugar) | C++17 | 312 ms | 15808 KB |
#include <bits/stdc++.h> using namespace std; int q,l; typedef pair<int,int> P; set<P> s; int main() { scanf("%d %d",&q,&l); long long ret=0; for(int i=0;i<q;i++) { int t,x,a; scanf("%d %d %d",&t,&x,&a); if (t==1) { auto iter=s.lower_bound(P(x,-1)); if (iter!=s.end()&&(*iter).first==x) { int val=(*iter).second+a; s.erase(iter); s.insert(P(x,val)); } else { s.insert(P(x,a)); } } else { auto iter=s.lower_bound(P(x-l,-1)); vector<P> er; while (1) { if (iter==s.end()) { break; } if (a==0) { break; } P now=(*iter); er.push_back(now); if (a<now.second) { s.insert(P(now.first,now.second-a)); ret+=a; break; } ret+=now.second; a-=now.second; iter++; } for(int j=0;j<er.size();j++) { s.erase(er[j]); } } printf("%lld\n",ret); } return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Incorrect | 1 ms | 212 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 304 KB | Output is correct |
2 | Incorrect | 1 ms | 212 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 179 ms | 11392 KB | Output is correct |
3 | Incorrect | 312 ms | 15808 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Incorrect | 1 ms | 212 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |