Submission #666256

#TimeUsernameProblemLanguageResultExecution timeMemory
666256BananCatfish Farm (IOI22_fish)C++17
0 / 100
43 ms10580 KiB
#include "fish.h" #include <bits/stdc++.h> using namespace std; using ll = long long; #define double long double #define endl '\n' #define sz(a) (int)a.size() #define pb push_back #define fs first #define sc second #define all(v) v.begin(), v.end() #define rall(v) v.rbegin(), v.rend() ll const INF = LONG_LONG_MAX; long long max_weights(int n, int m, std::vector<int> x, std::vector<int> y, std::vector<int> w) { vector<int> val(n+3, 0); for(int i=0;i<m;i++) val[x[i]]=w[i]; vector<vector<int>> dp(n+3, vector<int>(3, 0)); dp[0][1]=val[1]; for(int i=1;i<n;i++) { dp[i][0]=max(dp[i-1][0], dp[i-1][1]); dp[i][1]=val[i+1]; if(i==1){dp[i][1]+=max(dp[i-1][0]+val[i-1], dp[i-1][1]-val[i]);} else { dp[i][1]+=max(dp[i-2][0]+val[i-1], max(dp[i-2][1], dp[i-1][1]-val[i])); } } for(int i=0;i<n;i++) cout<<dp[i][0]<<' '; cout<<endl; for(int i=0;i<n;i++) cout<<dp[i][1]<<' '; return max(dp[n-1][0], dp[n-1][1]); }

Compilation message (stderr)

fish.cpp: In function 'long long int max_weights(int, int, std::vector<int>, std::vector<int>, std::vector<int>)':
fish.cpp:34:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   34 |     for(int i=0;i<n;i++)
      |     ^~~
fish.cpp:36:9: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   36 |         cout<<endl;
      |         ^~~~
#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...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...