답안 #90617

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
90617 2018-12-22T23:02:52 Z Harvey_Rollens 금 캐기 (IZhO14_divide) C++17
17 / 100
34 ms 2972 KB
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define st string
#define fr first
#define se second

const ll mod=1e9+7;

using namespace std;

ll p[100100], s[100100], n, a[100100];

int main()
{
    //freopen("1.txt", "r", stdin);
    //freopen("1.txt", "w", stdout);
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);

    ll ans=0;
    cin>>n;

    for(ll i=1; i<=n; i++)
    {
        ll g, e;
        cin>>a[i]>>g>>e;

        p[i]=e+p[i-1];
        s[i]=g+s[i-1];
        ans=max(ans, g);
    }

    ll l=1, r=1;
    while(l<=n)
    {
        while(p[r+1]-p[l-1]>=a[r+1]-a[l] && r+1<=n)
            r++;

        if(r==n && s[r]-s[l-1]<ans) break;
        ans=max(ans, s[r]-s[l-1]);

        l++;
        r=max(r, l);
    }

    cout<<ans;
    return 0;
}
/*
4 6 3
1 2 1
2 4 1
2 3 2
3 1 4
1 4 3
3 4 10
*/
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 448 KB Output is correct
4 Correct 2 ms 524 KB Output is correct
5 Correct 2 ms 668 KB Output is correct
6 Correct 2 ms 668 KB Output is correct
7 Correct 2 ms 668 KB Output is correct
8 Correct 2 ms 668 KB Output is correct
9 Correct 2 ms 668 KB Output is correct
10 Correct 2 ms 668 KB Output is correct
11 Correct 2 ms 668 KB Output is correct
12 Correct 2 ms 668 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 668 KB Output is correct
2 Correct 2 ms 668 KB Output is correct
3 Incorrect 2 ms 668 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 764 KB Output is correct
2 Correct 4 ms 764 KB Output is correct
3 Correct 4 ms 888 KB Output is correct
4 Correct 15 ms 1784 KB Output is correct
5 Correct 17 ms 1784 KB Output is correct
6 Correct 34 ms 2972 KB Output is correct
7 Correct 26 ms 2972 KB Output is correct
8 Correct 27 ms 2972 KB Output is correct
9 Correct 26 ms 2972 KB Output is correct
10 Incorrect 28 ms 2972 KB Output isn't correct
11 Halted 0 ms 0 KB -