Submission #1305817

#TimeUsernameProblemLanguageResultExecution timeMemory
1305817michael12Divide and conquer (IZhO14_divide)C++20
17 / 100
1 ms580 KiB
#include<bits/stdc++.h> #define ff first #define ss second #define pb push_back #define mp make_pair using namespace std; const int maxn = 5e5; struct camp{ int x, y, z; }; int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); int n; cin >> n; vector<camp> a(n); for(int i = 0; i < n; i++){ cin >> a[i].x >> a[i].y >> a[i].z; } long long E = 0; long long G = 0; int l = 0; long long mx = 0; for(int i = 0; i < n; i++){ G += a[i].y; E += a[i].z; while(l <= i && E < a[i].x - a[l].x){ G -= a[l].y; E -= a[l].z; l++; } if(l <= i && E >= a[i].x - a[l].x){ mx = max(mx, G); } } cout << mx; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...