제출 #1180338

#제출 시각아이디문제언어결과실행 시간메모리
1180338madamadam3메기 농장 (IOI22_fish)C++20
0 / 100
1095 ms9400 KiB
#include "fish.h" #include <bits/stdc++.h> using namespace std; using vi = vector<int>; typedef long long ll; /* Time log: - first start: 1048am - 3/100: 1100am - - first stop: - 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] */ ll max_weights(int N, int M, vi X, vi Y, vi W) { // subtask 2: x[i] <= 1: either use everything in col0, or col1 (as using 1 means you cant use the other) ll c0 = 0, c1 = 0; vi f0, f1; for (int i = 0; i < M; i++) { // cout << "i: " << i << " x: " << X[i] << " y: " << Y[i] << " W: " << W[i] << "\n"; if (X[i] == 0) { c0 += W[i]; f0.push_back(i); } else { c1 += W[i]; f1.push_back(i); } } int Z = (int) f0.size(), &&O = (int) f1.size(); // cout << "Z: " << Z << " O: " << O << "\n"; int i = 0, j = 0; ll v = c1; ll ans = v; while (i < Z || j < O) { if (i >= Z || ((j < O) && Y[f1[j]] < Y[f0[i]])) { v -= W[f1[j]]; j++; } else if (j >= O || ((i < Z) && Y[f0[i]] < Y[f1[j]])) { v += W[f0[i]]; ans = max(ans, v); i++; } } return ans; }
#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...