Submission #824866

#TimeUsernameProblemLanguageResultExecution timeMemory
824866alvingogoCatfish Farm (IOI22_fish)C++17
0 / 100
33 ms14296 KiB
#include "fish.h" #include <bits/stdc++.h> #define fs first #define sc second #define p_q priority_queue using namespace std; const int inf=1e16; long long max_weights(int n, int m, vector<int> x, vector<int> y, vector<int> w) { long long ans=0; vector<vector<pair<int,int> > > v(n); for(int i=0;i<m;i++){ v[x[i]].push_back({y[i],w[i]}); } vector<long long> dp[3]; dp[0].resize(n); dp[1].resize(n); dp[2].resize(n); dp[0][1]=-inf; for(int i=1;i<n;i++){ dp[i][0]=max({dp[i-1][0],dp[i-1][1]+v[i-1][0].sc,dp[i-1][2]}); dp[i][1]=max({dp[i-1][1],dp[i-1][2]}); dp[i][2]=dp[i-1][0]+v[i][0].sc; } return max({dp[n-1][0],dp[n-1][1],dp[n-1][2]}); }

Compilation message (stderr)

fish.cpp:8:15: warning: overflow in conversion from 'double' to 'int' changes value from '1.0e+16' to '2147483647' [-Woverflow]
    8 | const int inf=1e16;
      |               ^~~~
fish.cpp: In function 'long long int max_weights(int, int, std::vector<int>, std::vector<int>, std::vector<int>)':
fish.cpp:10:15: warning: unused variable 'ans' [-Wunused-variable]
   10 |     long long ans=0;
      |               ^~~
#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...