# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1186750 | ziyad_alharbi | 금 캐기 (IZhO14_divide) | C++20 | 0 ms | 328 KiB |
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define cc main
cc()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
int n;
cin>>n;
array<int,3>a[n];
vector<array<int,4>>st;
for(int x=0;x<n;x++)cin>>a[x][0]>>a[x][1]>>a[x][2];
int ans=0;
for(int x=n-1;x>=0;x--)
{
array<int,3>b=a[x];
int r=b[0];
while(st.size())
{
array<int,4>c=st.back();
if(c[1]-b[0]<=b[2]+c[3])
{
r=c[1];
b[2]+=c[3];
b[1]+=c[2];
st.pop_back();
}
else break;
}
ans=max(b[1],ans);
st.push_back({b[0],r,b[1],b[2]});
}
cout<<ans<<'\n';
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |