제출 #167753

#제출 시각아이디문제언어결과실행 시간메모리
167753daniyar03금 캐기 (IZhO14_divide)C++14
17 / 100
64 ms7160 KiB
#include<bits/stdc++.h> #define int long long int using namespace std; struct data{ int x,g,d; }; bool cmp(data l,data r){ return l.x<r.x||l.x==r.x&&l.d>r.d||l.x==r.x&&l.d==r.d&&l.g>r.g; } data a[100001]; int n,i,l,r,gold[100001],drive[100001],mx,m; main(){ scanf("%lld",&n); for(i=1;i<=n;i++)scanf("%lld%lld%lld",&a[i].x,&a[i].g,&a[i].d); sort(a+1,a+1+n,cmp); for(i=1;i<=n;i++)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; }

컴파일 시 표준 에러 (stderr) 메시지

divide.cpp: In function 'bool cmp(data, data)':
divide.cpp:8:29: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
     return l.x<r.x||l.x==r.x&&l.d>r.d||l.x==r.x&&l.d==r.d&&l.g>r.g;
                     ~~~~~~~~^~~~~~~~~
divide.cpp:8:58: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
     return l.x<r.x||l.x==r.x&&l.d>r.d||l.x==r.x&&l.d==r.d&&l.g>r.g;
                                        ~~~~~~~~~~~~~~~~~~^~~~~~~~~
divide.cpp: At global scope:
divide.cpp:12:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main(){
      ^
divide.cpp: In function 'int main()':
divide.cpp:13:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%lld",&n);
     ~~~~~^~~~~~~~~~~
divide.cpp:14: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);
                      ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...