Submission #344573

# Submission time Handle Problem Language Result Execution time Memory
344573 2021-01-06T06:08:35 Z l3nl3 Divide and conquer (IZhO14_divide) C++14
48 / 100
11 ms 1004 KB
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>  

#define exit exit(false)

//#define here() cerr << "herewego\n";
#define show(x) cerr << #x << ": " << x << '\n';

#define int long long
//#define double long double

#define all(a) a.begin(), a.end()
#define whole(a, p, q) a+p, a+p+q

#define ioio() ios_base::sync_with_stdio (0); cin.tie (0); cout.tie (0);

using namespace std;

//using namespace __gnu_pbds;   
//typedef tree <int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;  

const int sz = 5e3+7;

int n, x[sz], g[sz], d[sz], p[sz], pp[sz], mx, mxx;

signed main () { ioio();
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> x[i] >> g[i] >> d[i];
		p[i] = p[i-1] + d[i];
		pp[i] = pp[i-1] + g[i];
		mx = max (mx, g[i]);
	}
	mxx = mx;
	for (int i = 1; i <= n; i++) {
		int mj = i-1, ans = 0;
		for (int j = n; j >= i+1; j--) {
			if (x[j] - x[i] <= p[j] - p[i-1]) {
				ans += pp[j] - pp[i-1];
				break;
			}
		}
		mxx = max (mxx, ans);
	}
	cout << mxx;
}

Compilation message

divide.cpp: In function 'int main()':
divide.cpp:37:7: warning: unused variable 'mj' [-Wunused-variable]
   37 |   int mj = i-1, ans = 0;
      |       ^~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 364 KB Output is correct
2 Correct 0 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 0 ms 364 KB Output is correct
5 Correct 0 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 0 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 364 KB Output is correct
2 Correct 0 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 0 ms 364 KB Output is correct
5 Correct 0 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 0 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
16 Correct 1 ms 364 KB Output is correct
17 Correct 2 ms 364 KB Output is correct
18 Correct 1 ms 492 KB Output is correct
19 Correct 1 ms 364 KB Output is correct
20 Correct 1 ms 364 KB Output is correct
21 Correct 2 ms 492 KB Output is correct
22 Correct 3 ms 492 KB Output is correct
23 Correct 11 ms 620 KB Output is correct
24 Correct 11 ms 620 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 364 KB Output is correct
2 Correct 0 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 0 ms 364 KB Output is correct
5 Correct 0 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 0 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
16 Correct 1 ms 364 KB Output is correct
17 Correct 2 ms 364 KB Output is correct
18 Correct 1 ms 492 KB Output is correct
19 Correct 1 ms 364 KB Output is correct
20 Correct 1 ms 364 KB Output is correct
21 Correct 2 ms 492 KB Output is correct
22 Correct 3 ms 492 KB Output is correct
23 Correct 11 ms 620 KB Output is correct
24 Correct 11 ms 620 KB Output is correct
25 Correct 2 ms 620 KB Output is correct
26 Runtime error 3 ms 1004 KB Execution killed with signal 11 (could be triggered by violating memory limits)
27 Halted 0 ms 0 KB -