Submission #156810

#TimeUsernameProblemLanguageResultExecution timeMemory
156810LightningDivide and conquer (IZhO14_divide)C++14
48 / 100
1068 ms2552 KiB
#pragma GCC optimize ("O3")
#pragma GCC target ("avx,avx2")

#include <iostream>

using namespace std;

typedef long long ll;

#define fo(a, b, c, d) for(int (a) = (b); (a) <= (c); (a) += (d))
#define int ll

const int N = 2e5;
const int INF = 1e9;

struct rudina {
	int x, g, d;
} a[N];

int n, ans;

main () {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> n;
	fo(i, 1, n, 1) {
		cin >> a[i].x >> a[i].g >> a[i].d;
		//pref[i] = pref[i - 1] + a[i].g;
	}	
	fo(i, 1, n, 1) {
		int power = 0, gold = 0, ansGold = 0;
		fo(j, i, n, 1) {
			power += a[j].d;
			gold += a[j].g;
			if(power >= a[j].x - a[i].x) {
				ansGold = gold;
			}
		}
		ans = max(ans, ansGold); 
	}
	cout << ans;
	return 0;
}

Compilation message (stderr)

divide.cpp:22:7: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main () {
       ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...