| # | Time | Username | Problem | Language | Result | Execution time | Memory | 
|---|---|---|---|---|---|---|---|
| 1167839 | SmuggingSpun | Divide and conquer (IZhO14_divide) | C++20 | 13 ms | 328 KiB | 
#include<bits/stdc++.h>
#define taskname "A"
using namespace std;
typedef long long ll;
const int lim = 1e5 + 5;
template<class T>void maximize(T& a, T b){
    if(a < b){
        a = b;
    }
}
struct Data{
    int x, g, d;
    bool operator <(const Data& other){
        return this->x < other.x;
    }
};
int n;
Data a[lim];
namespace sub12{
    void solve(){
        sort(a + 1, a + n + 1);
        ll ans = 0;
        for(int i = 1; i <= n; i++){
            ll gold = 0, energy = 0;
            for(int j = i; j <= n; j++){
                gold += a[j].g;
                if((energy += a[j].d) >= a[j].x - a[i].x){
                    maximize(ans, gold);
                }
            }
        }
        cout << ans;
    }
}
int main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	if(fopen(taskname".inp", "r")){
		freopen(taskname".inp", "r", stdin);
	}
    cin >> n;
    for(int i = 1; i <= n; i++){
        cin >> a[i].x >> a[i].g >> a[i].d;
    }
    if(n <= 5000){
        sub12::solve();
    }
}
Compilation message (stderr)
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
