Submission #1293719

#TimeUsernameProblemLanguageResultExecution timeMemory
1293719activedeltorreAnts and Sugar (JOI22_sugar)C++20
0 / 100
4094 ms568 KiB
#include <iostream> #include <vector> #include <algorithm> using namespace std; int main() { long long i,j,k,l,n,m,q,t,nr,poz; ios_base::sync_with_stdio(false); cin.tie(NULL); cin>>q>>l; vector<pair<int,int>>v1; vector<pair<int,int>>v2; for(long long z=1;z<=q;z++) { cin>>t>>nr>>poz; if(t==1) { v1.push_back({nr,poz}); for(int i=v1.size()-2;i>=0;i--) { if(v1[i].first>v1[i+1].first) { swap(v1[i],v1[i+1]); } } } else { v2.push_back({nr,poz}); for(int i=v2.size()-2;i>=0;i--) { if(v2[i].first>v2[i+1].first) { swap(v2[i],v2[i+1]); } } } long long total=0,st=0,cons=0; for(long long i=0;i<v1.size();i++) { while(st<v2.size()) { while(v2[i].first<v1[st].first-l && st<v2.size()) { st++; cons=0; } while(v2[st].first<=v1[i].first+l && st<v2.size()) { long long util=v2[st].second-cons; if(util>=v1[i].second) { cons+=util; total+=util; break; } else { total+=util; st++; cons=0; } } } } cout<<total<<'\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...