#include<bits/stdc++.h>
#include "fish.h"
using namespace std;
#define fi first
#define se second
//#define int long long
#define sz(v) (int)(v).size()
#define all(v) (v).begin(), (v).end()
using ll = long long;
namespace Subtask1{
bool ckSub(vector<int>& X){
for(int i = 0; i < sz(X); i++){
if(X[i] & 1) return false;
}
return true;
}
ll process(vector<int>& W){
ll answer = 0;
for(int i = 0; i < sz(W); i++){
answer += W[i];
}
return answer;
}
}
namespace Subtask2{
bool ckSub(vector<int>& X){
for(int i = 0; i < sz(X); i++){
if(X[i] > 1) return false;
}
return true;
}
ll process(int n, vector<int>& X, vector<int>& Y, vector<int>& W){
vector<vector<int>> row(2, vector<int>(n + 1));
for(int i = 0; i < sz(X); i++){
row[X[i]][Y[i] + 1] = W[i];
}
vector<vector<ll>> pref(2, vector<ll>(n + 1));
for(int i = 0; i < 2; i++){
for(int j = 1; j <= n; j++){
pref[i][j] = pref[i][j - 1] + row[i][j];
}
}
ll answer = 0;
for(int i = 0; i <= n; i++){
for(int j = 0; j <= n; j++){
if(i > j){
answer = max(answer, pref[1][i] - pref[1][j]);
}
else{
answer = max(answer, pref[0][j] - pref[0][i]);
}
}
}
return answer;
}
}
ll max_weights(int n, int m, vector<int> X, vector<int> Y, vector<int> W){
if(Subtask1::ckSub(X)){
return Subtask1::process(W);
}
if(Subtask2::ckSub(X)){
return Subtask2::process(n, X, Y, W);
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |