답안 #721431

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
721431 2023-04-10T23:16:26 Z thimote75 금 캐기 (IZhO14_divide) C++14
17 / 100
1 ms 300 KB
#include <bits/stdc++.h>

using namespace std;

#define num long long
#define di pair<num, num>
#define cm pair<int, di>
#define vc vector<cm>

#define pos first
#define gold second.first
#define energy second.second

cm read () {
    int x, g, e;
    cin >> x >> g >> e;

    return { x, { g, e } };
}

vc camps;
int c_size (int left, int right) {
    return camps[right].pos - camps[left].pos;
}

int main () {
    int N;
    cin >> N;

    for (int i = 0; i < N; i ++)
        camps.push_back(read());
    
    sort(camps.begin(), camps.end());

    num energyCount = 0;
    num goldCount   = 0;

    num maxGoldCount = 0;

    int left = 0;
    for (int right = 0; right < N; right ++) {
        energyCount += camps[right].energy;
        goldCount   += camps[right].gold;

        while (energyCount < c_size(left, right)) {
            energyCount -= camps[left].energy;
            goldCount   -= camps[left].gold;
            left ++;
        }

        maxGoldCount = max(goldCount, maxGoldCount);
    }

    cout << maxGoldCount << endl;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 300 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 300 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 300 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 300 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 300 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 300 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 300 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 300 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 300 KB Output is correct
15 Incorrect 1 ms 212 KB Output isn't correct
16 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 300 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 300 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 300 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 300 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 300 KB Output is correct
15 Incorrect 1 ms 212 KB Output isn't correct
16 Halted 0 ms 0 KB -