# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
91054 | 2018-12-26T04:39:09 Z | Aydarov03 | Divide and conquer (IZhO14_divide) | C++14 | 24 ms | 704 KB |
#include <bits/stdc++.h> #define int long long #define fr first #define sc second using namespace std; pair<int , pair<int,int> > p[100005]; bool used[100005]; int ans; main() { int n; cin >> n; for(int i = 1; i <= n; i++) { scanf("%d%d%d" , &p[i].fr , &p[i].sc.fr , &p[i].sc.sc); } for(int now = 1; now <= n; now++) { int gold = 0 , place = p[now].fr; for(int i = now; i <= n; i++) { // cout << place << " " << gold << endl; gold += p[i].sc.fr; if( !used[i] ) { if( place + ( p[i].sc.sc - (place - p[i].fr) ) >= p[i+1].fr ) { place += ( p[i].sc.sc - (place - p[i].fr) ); used[i] = 1; continue; } else if( place + ( p[i].sc.sc - (place - p[i].fr) ) + p[i+1].sc.sc >= p[i+1].fr ) { place = p[i+1].fr; used[i] = used[i+1] = 1; continue; } else break; } else { if( p[i+1].fr - p[i+1].sc.sc <= place ) { used[i+1] = 1; place = p[i+1].fr; } else break; } } ans = max( ans , gold ); memset( used , 0 , sizeof(used) ); } cout << ans; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 500 KB | Output is correct |
3 | Correct | 2 ms | 500 KB | Output is correct |
4 | Correct | 2 ms | 500 KB | Output is correct |
5 | Correct | 2 ms | 704 KB | Output is correct |
6 | Correct | 2 ms | 704 KB | Output is correct |
7 | Incorrect | 2 ms | 704 KB | Output isn't correct |
8 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 3 ms | 704 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 24 ms | 704 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |