Submission #684214

# Submission time Handle Problem Language Result Execution time Memory
684214 2023-01-20T16:48:35 Z Urvuk3 Catfish Farm (IOI22_fish) C++17
9 / 100
85 ms 7280 KB
#include "fish.h"

#include <bits/stdc++.h>

using namespace std;

#define ll long long
const int INF=1e9;
const ll LINF=1e18;
#define fi first
#define se second
#define pii pair<int,int>
#define mid ((l+r)/2)
#define sz(a) (int((a).size()))
#define all(a) a.begin(),a.end()
#define endl "\n"
#define PRINT(x) cerr<<#x<<'='<<x<<endl;
#define pb push_back
#define PRINTvec(niz) { cerr<<#niz<<"="; for(auto _i:niz) cerr<<_i<<" "; cerr<<endl; }

long long max_weights(int N,int M,vector<int> X,vector<int> Y,vector<int> W){
    bool subtask1=true;
    for(int i=0;i<M;i++) subtask1&=(X[i]%2==0);
    if(subtask1){
        ll res=0;
        for(int i=0;i<M;i++){
            res+=W[i];
        }
        return res;
    }
    bool subtask2=true;
    for(int i=0;i<M;i++) subtask2&=(X[i]<=1);
    if(subtask2){
        ll res=0;
        ll sum0=0,sum1=0;
        for(int i=0;i<M;i++){
            if(X[i]==0){
                sum0+=W[i];
            }
            else{
                sum1+=W[i];
            }
        }
        res=max(sum1,sum0);
        if(N>2){
            sum0=0;
            vector<vector<int>> we(2,vector<int>(N,0));
            for(int i=0;i<M;i++){
                we[X[i]][Y[i]]=W[i];
            }
            for(int k=0;k<N;k++){
                sum0+=we[0][k];
                sum1-=we[1][k];
                res=max(res,sum0+sum1);
            }
        }
        return res;
    }
}

Compilation message

fish.cpp: In function 'long long int max_weights(int, int, std::vector<int>, std::vector<int>, std::vector<int>)':
fish.cpp:59:1: warning: control reaches end of non-void function [-Wreturn-type]
   59 | }
      | ^
# Verdict Execution time Memory Grader output
1 Correct 21 ms 2160 KB Output is correct
2 Correct 27 ms 2636 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 85 ms 7280 KB Output is correct
6 Correct 85 ms 7272 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 46 ms 5152 KB Output is correct
3 Correct 56 ms 6108 KB Output is correct
4 Correct 21 ms 2156 KB Output is correct
5 Correct 26 ms 2632 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 22 ms 3148 KB Output is correct
13 Correct 27 ms 3788 KB Output is correct
14 Correct 23 ms 3284 KB Output is correct
15 Correct 27 ms 3540 KB Output is correct
16 Correct 23 ms 3184 KB Output is correct
17 Correct 26 ms 3544 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Runtime error 2 ms 1996 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 468 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 468 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 468 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Runtime error 2 ms 1996 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 21 ms 2160 KB Output is correct
2 Correct 27 ms 2636 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 85 ms 7280 KB Output is correct
6 Correct 85 ms 7272 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 46 ms 5152 KB Output is correct
9 Correct 56 ms 6108 KB Output is correct
10 Correct 21 ms 2156 KB Output is correct
11 Correct 26 ms 2632 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 22 ms 3148 KB Output is correct
19 Correct 27 ms 3788 KB Output is correct
20 Correct 23 ms 3284 KB Output is correct
21 Correct 27 ms 3540 KB Output is correct
22 Correct 23 ms 3184 KB Output is correct
23 Correct 26 ms 3544 KB Output is correct
24 Correct 0 ms 212 KB Output is correct
25 Runtime error 2 ms 1996 KB Execution killed with signal 11
26 Halted 0 ms 0 KB -