답안 #167752

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
167752 2019-12-10T03:36:26 Z daniyar03 금 캐기 (IZhO14_divide) C++14
48 / 100
1000 ms 3320 KB
#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,j;
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++)
    for(j=i;j<=n;j++){
        if(drive[j]-drive[i-1]>=a[j].x-a[i].x)mx=max(mx,gold[j]-gold[i-1]);
    }
    cout<<mx;
}

Compilation message

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);
                      ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 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 376 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 248 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
# 결과 실행 시간 메모리 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 376 KB Output is correct
5 Correct 3 ms 376 KB Output is correct
6 Correct 4 ms 376 KB Output is correct
7 Correct 3 ms 376 KB Output is correct
8 Correct 3 ms 376 KB Output is correct
9 Correct 4 ms 376 KB Output is correct
10 Correct 5 ms 504 KB Output is correct
11 Correct 18 ms 632 KB Output is correct
12 Correct 17 ms 668 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 24 ms 632 KB Output is correct
2 Correct 86 ms 888 KB Output is correct
3 Correct 88 ms 952 KB Output is correct
4 Execution timed out 1074 ms 3320 KB Time limit exceeded
5 Halted 0 ms 0 KB -