Submission #1044694

#TimeUsernameProblemLanguageResultExecution timeMemory
1044694Dan4LifeCatfish Farm (IOI22_fish)C++17
0 / 100
197 ms481728 KiB
#include "fish.h" #include <bits/stdc++.h> using namespace std; #define pb push_back #define sz(a) (int)a.size() #define all(a) begin(a),end(a) using ll = long long; using vi = vector<int>; const int mxN = (int)1e5+10; const int mxN2 = (int)3e2+10; const ll LINF = (ll)2e18; int n, m; struct Fish{ int x, y; ll w; }; vector<Fish> fishes; ll dp[mxN2][mxN2][mxN2]; ll pref[4][mxN]; ll max_weights(int N, int M, vi _X, vi _Y, vi _W) { n = N, m = M; ll ans = 0; for(int i = 0; i < m; i++) fishes.pb({_X[i]+1,_Y[i]+1,_W[i]}); sort(all(fishes),[&](Fish a, Fish b){ if(a.x!=b.x) return a.x<b.x; return a.y<b.y; }); if(fishes.back().x <=2){ for(int i = 0; i < m; i++){ auto [x,y,w] = fishes[i]; pref[x][y]+=w; } for(int i = 0; i <= n; i++) for(int j = 1; j <= n; j++) pref[i][j]+=pref[i][j-1]; for(int i = 0; i <= n; i++){ ans = max({ans, pref[1][i], pref[2][i]}); } return ans; } }

Compilation message (stderr)

fish.cpp: In function 'll max_weights(int, int, vi, vi, vi)':
fish.cpp:40:1: warning: control reaches end of non-void function [-Wreturn-type]
   40 | }
      | ^
#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...