Submission #918009

#TimeUsernameProblemLanguageResultExecution timeMemory
918009borisAngelov금 캐기 (IZhO14_divide)C++17
17 / 100
1 ms348 KiB
#include <bits/stdc++.h>

using namespace std;

const int maxn = 100005;

int n;

struct Element
{
    int pos;
    int gold;
    int energy;
};

Element a[maxn];

void fastIO()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}

int main()
{
    fastIO();

    cin >> n;

    for (int i = 1; i <= n; ++i)
    {
        cin >> a[i].pos >> a[i].gold >> a[i].energy;
    }

    int ans = 0;

    for (int i = 1; i <= n; ++i)
    {
        int sumEnergy = 0;
        int sumGold = 0;

        for (int j = i; j <= n; ++j)
        {
            sumEnergy += a[j].energy;
            sumGold += a[j].gold;

            if (sumEnergy >= a[j].pos - a[i].pos)
            {
                ans = max(ans, sumGold);
            }
        }
    }

    cout << ans << endl;

    return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...