Submission #814936

#TimeUsernameProblemLanguageResultExecution timeMemory
814936konstantysAnts and Sugar (JOI22_sugar)C++14
6 / 100
4073 ms10304 KiB
#include<iostream> #include<cstdlib> #include<vector> #include<cassert> #include<set> #define ll long long using namespace std; ll q,l,a,b,c,d; set<pair<int,ll>> A,C; int main(){ ios_base::sync_with_stdio(0); cin>>q>>l; for(int i=0;i<q;i++){ cin>>a>>b>>c; if(a==1) A.insert({b+l,c}); else C.insert({b,c}); set<pair<int,ll>>::iterator it1=A.begin(),it2=C.begin(); ll wyn=0; d=it2->second; c=it1->second; while(true){ if(it1==A.end()) break; while(it2!=C.end() && it2->first+2*l<it1->first){ it2++; d=it2->second; } if(it2==C.end()) break; //d=it2->second; while(it2!=C.end() && c && it2->first<=it1->first){ if(d>c){ d-=c; wyn+=c; break; } c-=d; wyn+=d; it2++; d=it2->second; } it1++; if(it1==A.end()) break; c=it1->second; } cout<<wyn<<"\n"; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...