# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
69609 | 2018-08-21T10:00:34 Z | khohko | Homecoming (BOI18_homecoming) | C++17 | 214 ms | 35940 KB |
#include<bits/stdc++.h> #include "homecoming.h" using namespace std; #define ll long long #define fr first #define sc second #define pb push_back #define ARRS ((ll)(2e6+100)) #define MAX ((ll)(1e12+100)) ll a[ARRS]; ll b[ARRS]; ll s[ARRS]; ll dp[ARRS][2]; ll sum(ll l,ll r){ return s[r]-s[l-1]; } long long solve(int n, int K, int *B, int *A){ ll pas=0,p=0; for(int i=1; i<=n; i++){ a[i]=A[i-1]; a[i+n]=A[i-1]; b[i]=B[i-1]; b[i+n]=B[i-1]; p-=a[i]; p+=b[i]; } for(int i=1; i<=2*n; i++)s[i]=s[i-1]+a[i]; pas=max(pas,p); ll ct=50; while(ct--){ ll s=abs(rand()<<16ll+rand())%n; dp[0][0]=0; dp[0][1]=-MAX; for(int i=1; i<=n; i++){ dp[i][0]=dp[i-1][0]; dp[i][1]=-MAX; if(i>=K){ dp[i][1]=max(dp[i][1],dp[i-K][0]+b[i-K+1+s]-sum(i-K+1+s,i+s)); dp[i][1]=max(dp[i][1],dp[i-1][1]+b[i-K+1+s]-a[i+s]); } dp[i][0]=max(dp[i][0],dp[i][1]); //cout<<dp[i][0]<<" "<<dp[i][1]<<endl; } pas=max(pas,dp[n][0]); //cout<<endl; } return pas; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 376 KB | Output is correct |
2 | Correct | 3 ms | 616 KB | Output is correct |
3 | Correct | 3 ms | 616 KB | Output is correct |
4 | Correct | 3 ms | 616 KB | Output is correct |
5 | Correct | 4 ms | 616 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 376 KB | Output is correct |
2 | Correct | 3 ms | 616 KB | Output is correct |
3 | Correct | 3 ms | 616 KB | Output is correct |
4 | Correct | 3 ms | 616 KB | Output is correct |
5 | Correct | 4 ms | 616 KB | Output is correct |
6 | Correct | 3 ms | 896 KB | Output is correct |
7 | Correct | 4 ms | 896 KB | Output is correct |
8 | Correct | 4 ms | 896 KB | Output is correct |
9 | Correct | 4 ms | 952 KB | Output is correct |
10 | Incorrect | 6 ms | 952 KB | Output isn't correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 214 ms | 35940 KB | Output is correct |
2 | Correct | 14 ms | 35940 KB | Output is correct |
3 | Runtime error | 156 ms | 35940 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 376 KB | Output is correct |
2 | Correct | 3 ms | 616 KB | Output is correct |
3 | Correct | 3 ms | 616 KB | Output is correct |
4 | Correct | 3 ms | 616 KB | Output is correct |
5 | Correct | 4 ms | 616 KB | Output is correct |
6 | Correct | 3 ms | 896 KB | Output is correct |
7 | Correct | 4 ms | 896 KB | Output is correct |
8 | Correct | 4 ms | 896 KB | Output is correct |
9 | Correct | 4 ms | 952 KB | Output is correct |
10 | Incorrect | 6 ms | 952 KB | Output isn't correct |