답안 #37395

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
37395 2017-12-25T04:25:57 Z adlet 금 캐기 (IZhO14_divide) C++14
0 / 100
186 ms 10956 KB
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int N = 1e5 + 5;

int n, l, x[N], g[N], e[N];

ll de[N], dg[N], ans;

set < pair < ll, int > > st;

int main() {
//    freopen("divide.in", "r", stdin);
//    freopen("divide.out", "w", stdout);
    cin >> n;
    for (int i = 1; i <= n + 1; ++i) {
        if (i != n + 1) {
            cin >> x[i] >> g[i] >> e[i];
            dg[i] += dg[i - 1] + g[i];
            de[i] += de[i - 1] + e[i];
        }
        ans = max(ans, 1ll * g[i]);
        if (i > 1) {
            int l = st.begin()->second;
            if (x[i] - x[l] <= de[i] - de[l - 1] && dg[i] - dg[l - 1] > ans) {
                ans = dg[i] - dg[l - 1];
            }
        }
        st.insert({dg[i], i});
     }
//    for (int l = 1; l <= n; ++l) {
//        for (int r = l; r <= n; ++r) {
//            if (x[r] - x[l] <= de[r] - de[l - 1] && dg[r] - dg[l - 1] > ans) {
//                ans = dg[r] - dg[l - 1];
//            }
//        }
//    }
    cout << ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 4752 KB Output is correct
2 Incorrect 0 ms 4752 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 4752 KB Output is correct
2 Correct 0 ms 4752 KB Output is correct
3 Incorrect 0 ms 4752 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 5016 KB Output is correct
2 Correct 9 ms 5412 KB Output is correct
3 Correct 9 ms 5412 KB Output is correct
4 Correct 66 ms 7920 KB Output is correct
5 Correct 83 ms 7920 KB Output is correct
6 Correct 186 ms 10956 KB Output is correct
7 Correct 139 ms 10956 KB Output is correct
8 Correct 146 ms 10956 KB Output is correct
9 Correct 146 ms 10956 KB Output is correct
10 Incorrect 139 ms 10956 KB Output isn't correct
11 Halted 0 ms 0 KB -