# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
955001 | IUA_Hasin | Catfish Farm (IOI22_fish) | C++17 | 88 ms | 25176 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#define endl "\n"
#define finp for(int i=0; i<n; i++)
#define fknp for(int k=0; k<n; k++)
#define yeap cout<<"YES"<<endl
#define nope cout<<"NO"<<endl
#define inpintn int n; cin>>n
#define inpintarrn int arr[n]; for(int i=0; i<n; i++){cin>>arr[i];}
#define inpllarrn long long arr[n]; for(int i=0; i<n; i++){cin>>arr[i];}
#define ll long long
using namespace std;
#include "fish.h"
#include <vector>
long long max_weights(int N, int M, std::vector<int> X, std::vector<int> Y,
std::vector<int> W) {
ll vis0[N];
ll vis1[N];
ll sum0 = 0;
ll sum1 = 0;
vector<ll> v0[N];
vector<ll> v1[N];
for(int i=0; i<N; i++){
vis0[i] = 0;
vis1[i] = 0;
}
for(int i=0; i<M; i++){
ll a = Y[i];
ll b = W[i];
if(X[i]==0){
vis0[a] = 1;
sum0 = sum0+b;
v0[a].push_back(b);
} else {
vis1[a] = 1;
sum1 = sum1+b;
v1[a].push_back(b);
}
}
if(N==2){
ll ans = max(sum0, sum1);
return ans;
} else {
ll ans = sum1;
ll l = 0;
ll r = sum1;
for(int i=0; i<N; i++){
if(i<N-1){
if(vis0[i]==1){
ll c = v0[i][0];
l = l+c;
}
if(vis1[i]==1){
ll c = v1[i][0];
r = r-c;
}
ll temp = l+r;
ans = max(temp, ans);
} else {
ll temp = sum0;
ans = max(temp, ans);
}
}
return ans;
}
// ll ans = sum1;
// ll l = 0;
// ll r = sum1;
// for(int i=0; i<N; i++){
// if(i<N-1){
// if(vis0[i]==1){
// ll c = v0[i][0];
// l = l+c;
// }
// if(vis1[i]==1){
// ll c = v1[i][0];
// r = r-c;
// }
// ll temp = l+r;
// ans = max(temp, ans);
// } else {
// ll temp = sum0;
// ans = max(temp, ans);
// }
// }
// return ans;
// 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... |