Submission #1121021

#TimeUsernameProblemLanguageResultExecution timeMemory
1121021TsaganaDivide and conquer (IZhO14_divide)C++14
48 / 100
1058 ms2772 KiB
#include<bits/stdc++.h> #define IOS ios_base::sync_with_stdio(false);cin.tie();cout.tie(); #define all(x) x.begin(), x.end() #define int long long #define pq priority_queue #define eb emplace_back #define lb lower_bound #define ub upper_bound #define pb push_back #define pp pop_back #define F first #define S second using namespace std; int g[100001]; int e[100001]; vector<int> v; void solve () { int n; cin >> n; for (int i = 0; i < n; i++) { int x; cin >> x >> g[i] >> e[i]; v.pb(x); } int ans = 0; for (int i = 0; i < n; i++) { int c = e[i]-1; int val = g[i]; int l = i, r = i+1; ans = max(ans, val); for (int j = i+1; j < n; j++) { c += e[j]; val += g[j]; if (v[j] - v[i] <= c) ans = max(ans, val); } } cout << ans; } signed main() {IOS solve(); return 0;}

Compilation message (stderr)

divide.cpp: In function 'void solve()':
divide.cpp:31:7: warning: unused variable 'l' [-Wunused-variable]
   31 |   int l = i, r = i+1;
      |       ^
divide.cpp:31:14: warning: unused variable 'r' [-Wunused-variable]
   31 |   int l = i, r = i+1;
      |              ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...