답안 #167826

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
167826 2019-12-10T09:53:49 Z juggernaut 금 캐기 (IZhO14_divide) C++14
0 / 100
50 ms 1528 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,cnt=1;
main(){
    scanf("%lld",&n);
    cin>>a[1].x>>a[1].g>>a[1].d;
    for(i=2;i<=n;i++)
    {
        scanf("%lld%lld%lld",&x,&g,&d);
        if(a[cnt].x + a[cnt].d >= x){
            a[cnt].d+=d;
            a[cnt].g+=g;
        }
        else{
            cnt++;
            a[cnt].x=x;
            a[cnt].d=d;
            a[cnt].g=g;

        }
    }
    n=cnt;
    l=r=n;
    x=a[n].x;
    g=0;
    d=0;
    while(l>0){
        if(d+a[l].d>=a[r].x-a[l].x){

            d+=a[l].d;
            g+=a[l].g;
            mx=max(mx,g);
            l--;
        }else{
            g-=a[r].g;
            d-=a[r].d;
            r--;
            x=a[r].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:14:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%lld%lld%lld",&x,&g,&d);
         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 380 KB Output is correct
7 Correct 2 ms 256 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Incorrect 2 ms 376 KB Output isn't correct
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Incorrect 2 ms 276 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 256 KB Output is correct
3 Correct 5 ms 256 KB Output is correct
4 Correct 20 ms 376 KB Output is correct
5 Correct 24 ms 348 KB Output is correct
6 Correct 50 ms 376 KB Output is correct
7 Correct 35 ms 376 KB Output is correct
8 Correct 36 ms 480 KB Output is correct
9 Correct 34 ms 256 KB Output is correct
10 Incorrect 37 ms 1528 KB Output isn't correct
11 Halted 0 ms 0 KB -