# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1156269 | AI_2512 | Divide and conquer (IZhO14_divide) | C++17 | 2 ms | 320 KiB |
#include <bits/stdc++.h>
#define int long long
#define ss second
#define ff first
using namespace std;
signed main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
int n;cin >> n;
vector<pair<int,pair<int,int>>> a(n);
for (int i = 0; i< n;i++) cin >> a[i].ff >> a[i].ss.ff >> a[i].ss.ss;
int mx = 0;
for (int i =0 ; i< n;i++){
mx = max(mx, a[i].ss.ff);
}
int l = 0, r = 0;
int curg = 0, cure = 0;
while (r < n){
curg+=a[r].ss.ff;
cure+=a[r].ss.ss;
if (cure < a[r].ff-a[l].ff){
mx = max(mx, curg-a[r].ss.ff);
while (cure < a[r].ff-a[l].ff){
curg-=a[l].ss.ff;
cure-=a[l].ss.ss;
l--;
}
}
r++;
}
cout << mx;
}
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... |