Submission #833813

#TimeUsernameProblemLanguageResultExecution timeMemory
833813BilAktauAlmansurDivide and conquer (IZhO14_divide)C++17
48 / 100
1094 ms2460 KiB
#include <bits/stdc++.h> // #pragma optimize ("g",on) // #pragma GCC optimize ("inline") // #pragma GCC optimize ("Ofast") // #pragma GCC optimize ("unroll-loops") // #pragma GCC optimize ("03") // #pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,avx2,mmx,fma,avx,tune=native") // #pragma comment(linker, "/stack:200000000") #define int long long using namespace std; const int N = 1e5 + 7; int n; pair<int, pair<int, int> > a[N]; signed main() { // freopen("bank.in", "r", stdin); // freopen("bank.out", "w", stdout); ios_base::sync_with_stdio(NULL); cin.tie(NULL); cin>>n; for(int i = 1; i <= n; i++) { int pos, d, x; cin>>pos>>d>>x; a[i].first = pos, a[i].second.first = d, a[i].second.second = x; } sort(a + 1, a + 1 + n); int ans = 0; for(int i = 1; i <= n; i++) { int sum_d = 0, sum_x = 0; for(int j = i; j <= n; j++) { sum_x += a[j].second.second, sum_d += a[j].second.first; int len = a[j].first - a[i].first; if(len <= sum_x) { // cout << i << ' ' << j << ' ' << len << ' ' << sum_x << '\n'; ans = max(ans, sum_d); } } } cout << ans << '\n'; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...