제출 #1180574

#제출 시각아이디문제언어결과실행 시간메모리
1180574madamadam3메기 농장 (IOI22_fish)C++20
0 / 100
15 ms4792 KiB
#include "fish.h" #include <bits/stdc++.h> using namespace std; using vi = vector<int>; typedef long long ll; #define sz(x) (int) (x).size() #define all(x) (x).begin(), (x).end() #define pb push_back int N, M; vi X, Y, 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 2: x[i] <= 1: either use everything in col0, or col1 (as using 1 means you cant use the other) ll c1 = 0; ll fish[2][N]; for (int i = 0; i < M; i++) { // cout << "i: " << i << " x: " << X[i] << " y: " << Y[i] << " W: " << W[i] << "\n"; if (X[i] == 1) { c1 += W[i]; fish[1][Y[i]] = W[i]; } else if (X[i] == 0) { fish[0][Y[i]] = W[i]; } } ll c0 = 0; ll ans = c1; for (int i = 0; i < N; i++) { c1 -= fish[1][i]; c0 += fish[0][i]; ans = max(ans, c0 + c1); } return max(ans, c1); }
#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...