답안 #167745

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
167745 2019-12-10T03:19:02 Z daniyar03 금 캐기 (IZhO14_divide) C++14
0 / 100
2 ms 312 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,gold[100001],drive[100001],mx,m;
main(){
    freopen("divide.in","r",stdin);
    freopen("divide.out","w",stdout);
    scanf("%lld",&n);
    for(i=1;i<=n;i++)scanf("%lld%lld%lld",&a[i].x,&a[i].g,&a[i].d),gold[i]=gold[i-1]+a[i].g,drive[i]=drive[i-1]+a[i].d;
    for(i=1;i<=n;i++){
        l=i;
        r=n;
        while(l<r){
            m=(l+r+1)>>1;
            if(drive[m]-drive[i-1]>=a[m].x-a[i].x)l=m;
            else r=m-1;
        }
        mx=max(mx,gold[l]-gold[i-1]);
    }
    cout<<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:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
     freopen("divide.in","r",stdin);
     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
divide.cpp:11:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
     freopen("divide.out","w",stdout);
     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
divide.cpp:12:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%lld",&n);
     ~~~~~^~~~~~~~~~~
divide.cpp:13:92: 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),gold[i]=gold[i-1]+a[i].g,drive[i]=drive[i-1]+a[i].d;
                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 312 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -