# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
745729 | 2023-05-21T05:46:27 Z | inventiontime | 메기 농장 (IOI22_fish) | C++17 | 0 ms | 0 KB |
#include "fish.h" #include <bits/stdc++.h> using namespace std; #define pb push_back #define re resize #define ff first #define ss second #define all(x) (x).begin(), (x).end() #define all1(x) (x).begin()+1, (x).end() #define loop(i, n) for(int i = 0; i < n; i++) #define loop1(i, n) for(int i = 1; i <= n; i++) #define print(x) cout << #x << ": " << x << endl << flush template<class T> bool ckmin(T&a, T b) { bool B = a > b; a = min(a, b); return B; } template<class T> bool ckmax(T&a, T b) { bool B = a < b; a = max(a, b); return B; } typedef long long ll; typedef vector<int> vi; ll max_weights(int n, int m, vi x, vi y, vi w) { ll fish[2][n] = {}; loop(i, m) fish[x[i]][y[i]] = w[i]; ll res = 0; ll diff[n]; loop1(i, n-1) fish[0][i] += fish[0][i-1]; loop1(i, n-1) fish[1][i] += fish[1][i-1]; res = max(fish[0][n-1], fish[1][n-1]); if(n >= 3) loop1(i, n-1) ckmax(res, fish[1][n-1] + fish[0][i] - fish[1][i]); return res; }