Submission #372772

# Submission time Handle Problem Language Result Execution time Memory
372772 2021-03-01T15:16:43 Z cpp219 코알라 (JOI13_koala) C++14
20 / 100
2000 ms 4460 KB
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define fs first
#define sc second
using namespace std;
typedef pair<ll,ll> LL;
const ll N = 1e5 + 9;
const ll inf = 1e18 + 7;
LL a[N];
ll K,M,D,A,n,dp[N];


int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    #define task "tst"
    if (fopen(task".INP","r")){
        freopen(task".INP","r",stdin);
        //freopen(task".OUT","w",stdout);
    }
    cin>>K>>M>>D>>A>>n; a[1].fs = K; a[n + 2].fs = M; n += 2;
    for (ll i = 2;i < n;i++) cin>>a[i].fs>>a[i].sc;
    for (ll i = n - 1;i > 0;i--){
        dp[i] = -inf;
        for (ll j = i + 1;j <= n;j++){
            ll dis = a[j].fs - a[i].fs;
            ll kq = dp[j] + a[j].sc - A * ceil((ld)dis/D);
            dp[i] = max(dp[i],kq);
        }
    }
    cout<<dp[1];
}

Compilation message

koala.cpp:2: warning: ignoring #pragma GCC optimization [-Wunknown-pragmas]
    2 | #pragma GCC optimization ("O3")
      | 
koala.cpp:3: warning: ignoring #pragma GCC optimization [-Wunknown-pragmas]
    3 | #pragma GCC optimization ("unroll-loops")
      | 
koala.cpp: In function 'int main()':
koala.cpp:23:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   23 |         freopen(task".INP","r",stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 4 ms 364 KB Output is correct
2 Correct 4 ms 364 KB Output is correct
3 Correct 3 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 3 ms 364 KB Output is correct
6 Correct 4 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 4 ms 364 KB Output is correct
9 Correct 4 ms 364 KB Output is correct
10 Correct 4 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 2077 ms 4460 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2070 ms 4204 KB Time limit exceeded
2 Halted 0 ms 0 KB -