제출 #1180615

#제출 시각아이디문제언어결과실행 시간메모리
1180615madamadam3메기 농장 (IOI22_fish)C++20
3 / 100
53 ms14008 KiB
#include "fish.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; using vi = vector<int>; using vl = vector<ll>; #define sz(x) (int) (x).size() #define all(x) (x).begin(), (x).end() #define pb push_back /* Time log: - first start: 1048am - 3/100: 1100am - first stop: 1128am - second start: 337pm - 416pm finally stopped being stupid and got 9/100 (+6 points) - second end: - overall time used: */ /* NxN grid of cells grid[c][r] = the cell at column c row r grid[0][r] is the westernmost point, and grid[N-1][r] is the easternmost point grid[c][0] = southernmost point, grid[c][N-1] northermost point M catfishes X[i], Y[i] for i < M are column and row of fish i W[i] = weight of fish i a catfish can be caught if grid[ci][ri] is empty and grid[ci-1][ri] or grid[ci+1][ri] has a pier tile a pier extends from grid[cP][0] to grid[cP][rP] */ int N, M; vi X, Y; vector<ll> W; bool cmp(int a, int b) { // compare two fish in the same col return Y[a] < Y[b]; } ll max_weights(int _N, int _M, vi _X, vi _Y, vi _W) { N = _N; M = _M; X = _X; Y = _Y; for (int i = 0; i < M; i++) W.pb(ll(_W[i])); // subtask 3: y[i] = 0 for all i, so just do a dp where DP[i][use] = max(DP[i-2][use] + W[i], DP[i-1][!use] + w[i]) vl Weights(N, 0LL); for (int i = 0; i < M; i++) Weights[X[i]] += W[i]; ll tl = 0LL; for (int i = 0; i < N; i++) tl += Weights[i]; if (N == 2) return max(Weights[0], Weights[1]); vl f(N+3, 0LL); f[N] = f[N+1] = f[N+2] = 0; f[N-1] = Weights[N-1]; for (int i = N - 2; i >= 0; i--) { ll option1 = Weights[i] + f[i+2]; ll option2 = (i+1 < N ? Weights[i+1] + f[i+3] : LLONG_MAX); f[i] = min(option1, option2); } ll bestCost = f[0]; return tl - bestCost; }
#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...