| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1293726 | activedeltorre | Ants and Sugar (JOI22_sugar) | C++20 | 1 ms | 572 KiB |
#include <iostream>
#include <vector>
#include <algorithm>
#pragma gcc optimize("O3,unroll-loops")
using namespace std;
signed 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<long long,long long>>v1;
vector<pair<long long,long long>>v2;
for(long long z=1; z<=q; z++)
{
cin>>t>>nr>>poz;
if(t==1)
{
v1.push_back({nr,poz});
for(long long i=v1.size()-2; i>=0; i--)
{
if(v1[i].first>v1[i+1].first)
{
swap(v1[i],v1[i+1]);
}
else
{
break;
}
}
}
else
{
v2.push_back({nr,poz});
for(long long i=v2.size()-2; i>=0; i--)
{
if(v2[i].first>v2[i+1].first)
{
swap(v2[i],v2[i+1]);
}
else
{
break;
}
}
}
long long total=0,st=0,cons=0;
for(long long i=0; i<v1.size(); i++)
{
if(st<v2.size())
{
while(v2[st].first<v1[i].first-l && st<v2.size())
{
st++;
cons=0;
}
if(st<v2.size())
{
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 time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
