Submission #1089854

#TimeUsernameProblemLanguageResultExecution timeMemory
1089854KALARRYTricks of the Trade (CEOI23_trade)C++14
25 / 100
8066 ms12884 KiB
//chockolateman #include<bits/stdc++.h> using namespace std; long long N,K,a[250005],b[250005],dp[250005][2]; int main() { scanf("%lld%lld",&N,&K); for(long long i = 1 ; i <= N ; i++) scanf("%lld",&a[i]); for(long long i = 1 ; i <= N ; i++) scanf("%lld",&b[i]); for(long long j = 1 ; j <= K ; j++) dp[0][j%2] = -1e15; for(long long j = 1 ; j <= K ; j++) { for(long long i = 1 ; i <= N ; i++) dp[i][j%2] = max(dp[i-1][j%2] - a[i],dp[i-1][(j-1)%2] + b[i] - a[i]); } long long ans = -1e15; for(long long i = 1 ; i <= N ; i++) ans = max(ans,dp[i][K%2]); printf("%lld\n",ans); return 0; }

Compilation message (stderr)

trade.cpp: In function 'int main()':
trade.cpp:11:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   11 |     scanf("%lld%lld",&N,&K);
      |     ~~~~~^~~~~~~~~~~~~~~~~~
trade.cpp:13:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |         scanf("%lld",&a[i]);
      |         ~~~~~^~~~~~~~~~~~~~
trade.cpp:15:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   15 |         scanf("%lld",&b[i]);
      |         ~~~~~^~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...