답안 #342905

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
342905 2021-01-03T07:59:29 Z Habib_Assoev 금 캐기 (IZhO14_divide) C++14
0 / 100
1000 ms 127468 KB
# include<bits/stdc++.h>
#define in freopen ("divide.in", "r", stdin);
#define out freopen("divide.out", "w", stdout);
#define ll long long
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define speed ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std ;
long long const N = 1e6 + 7;
long long N1 = 1e9 + 7;
int main( ){
    in out
    speed ;
    ll TJK = 1 ;
    // cin >> TJK ;
    while( TJK -- ){
        ll n;
        cin >> n;
        ll a[n] , g[n] , d[n];
        for( int i = 0 ; i < n ; i ++ ){
            cin >> a[i] >> g[i] >> d[i];
        }
        ll g1[n] , d1[n];
        g1[0] = g[0] , d1[0] = d[0];
        for( int i = 1 ; i < n ; i ++ ){
            g1[i] = g[i] + g1[i-1];
            d1[i] = d[i] + d1[i-1];
        }
        ll mx = 0;
        for( int i = 0 ; i < n ; i ++ ){
            for( int j = i ; j < n ; j ++ ){
                ll k = a[j] - a[i];
                ll r = ( d1[j] - d1[i] ) + d[i];
                ll e = ( g1[j] - g1[i] ) + g[i];
                //cout << i << ' ' << j << ' ' << k << ' ' << r << ' ' << e << endl;
                if( r >= k ){
                    mx = max( mx , e );
                }
            }
        }
        cout << mx << endl;
    }
}

Compilation message

divide.cpp: In function 'int main()':
divide.cpp:2:20: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
    2 | #define in freopen ("divide.in", "r", stdin);
      |            ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
divide.cpp:14:5: note: in expansion of macro 'in'
   14 |     in out
      |     ^~
divide.cpp:3:20: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
    3 | #define out freopen("divide.out", "w", stdout);
      |             ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
divide.cpp:14:8: note: in expansion of macro 'out'
   14 |     in out
      |        ^~~
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1069 ms 127468 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1069 ms 127468 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1069 ms 127468 KB Time limit exceeded
2 Halted 0 ms 0 KB -