답안 #167201

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
167201 2019-12-06T14:00:27 Z muhammad_hokimiyon 금 캐기 (IZhO14_divide) C++14
0 / 100
4 ms 504 KB
#include <bits/stdc++.h>

#pragma GCC optimize("Ofast")

#define fi first
#define se second
#define LL long long

using namespace std;

const int N = 2e5 + 7;
const int mod = 1e9 + 7;

int n;
int x[N];
LL g[N];
LL d[N];
LL pg[N];
LL pd[N];

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

    cin >> n;
    LL ans = 0;
    for( int i = 1; i <= n; i++ ){
        cin >> x[i] >> g[i] >> d[i];
        ans = max( ans , g[i] );
    }
    for( int i = 1; i <= n; i++ ){
        pg[i] = pg[i - 1] + g[i];
        pd[i] = pd[i - 1] + d[i];
    }
    for( int i = 1; i <= n; i++ ){
        int l = i , r = n;
        while( r - l > 3 ){
            int m1 = l + (r - l) / 3;
            int m2 = r - (r - l) / 2;
            if( pd[m1] - pd[i - 1] <= x[m2] - x[i] ){
                l = m1;
            }
            else r = m2;
        }
        for( ; l <= r; l++ ){
            if( x[l] - x[i] <= pd[l] - pd[i - 1] ){
                ans = max( ans , pg[l] - pg[i - 1] );
            }
        }
    }
    cout << ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Incorrect 3 ms 376 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 4 ms 504 KB Output isn't correct
2 Halted 0 ms 0 KB -