답안 #167813

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
167813 2019-12-10T09:26:18 Z juggernaut 금 캐기 (IZhO14_divide) C++14
0 / 100
50 ms 2680 KB
#include<bits/stdc++.h>
#define int long long int
using namespace std;
struct data{
    int x,g,d;
};
data a[100001];
int n,i,l,r,x,g,mx,d;
main(){
    scanf("%lld",&n);
    for(i=1;i<=n;i++)scanf("%lld%lld%lld",&a[i].x,&a[i].g,&a[i].d);
    l=r=1;
    x=a[1].x;
    g=a[1].g;
    d=a[1].d;
    while(r<=n&&l<=n){
        if(r<n&&d+a[r+1].d>=a[r+1].x-x){
            r++;
            d+=a[r].d;
            g+=a[r].g;
            mx=max(mx,g);
        }else{
            g-=a[l].g;
            d-=a[l].d;
            l++;
            x=a[l].x;
        }
    }
    printf("%lld",mx);
}

Compilation message

divide.cpp:9:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main(){
      ^
divide.cpp: In function 'int main()':
divide.cpp:10:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%lld",&n);
     ~~~~~^~~~~~~~~~~
divide.cpp:11:27: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for(i=1;i<=n;i++)scanf("%lld%lld%lld",&a[i].x,&a[i].g,&a[i].d);
                      ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Incorrect 2 ms 376 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 376 KB Output is correct
2 Correct 5 ms 508 KB Output is correct
3 Correct 6 ms 504 KB Output is correct
4 Correct 21 ms 1532 KB Output is correct
5 Correct 25 ms 1528 KB Output is correct
6 Correct 50 ms 2680 KB Output is correct
7 Correct 36 ms 2680 KB Output is correct
8 Correct 37 ms 2680 KB Output is correct
9 Correct 35 ms 2680 KB Output is correct
10 Incorrect 36 ms 2680 KB Output isn't correct
11 Halted 0 ms 0 KB -