Submission #715983

# Submission time Handle Problem Language Result Execution time Memory
715983 2023-03-28T17:03:58 Z Huseyn123 Catfish Farm (IOI22_fish) C++17
6 / 100
110 ms 10092 KB
#include "fish.h"
#include <bits/stdc++.h>
#define MAX 300001
#define INF LLONG_MAX
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define ins insert
#define ff first
#define ss second
#define gett(x,m) get<m>(x)
#define all(a) a.begin(),a.end()
#define lb(a,b) lower_bound(all(a),b)
#define ub(a,b) upper_bound(all(a),b)
#define sortv(a) sort(all(a))
#define sorta(a,sz) sort(a,a+sz)
#define inputar(a,b){\
    for(int i=0;i<b;i++){\
        cin >> a[i];\
    }\
}
#define inputvec(a,b){\
    for(int i=0;i<b;i++){\
        ll num;\
        cin >> num;\
        a.pb(num);\
    }\
}
#define outputar(a,b){\
    for(int i=0;i<b;i++){\
        cout << a[i] << " ";\
    }\
    cout << "\n";\
}
#define outputvec(a){\
    for(auto x:a){\
        cout << x << " ";\
    }\
    cout << "\n";\
}
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef tuple<ll,ll,ll> tll;
typedef pair<ll,ll> pll;
typedef double db;
typedef long double ldb;
ll n,q,t=1,m,n2,m2,k,cnt=0,a[MAX],b[MAX],d[MAX],d2[MAX],x,y,z,x2,y2,z2,res1=0,cnt1,cnt2,cnt3;
long long max_weights(int N, int M, vector<int> X, vector<int> Y, vector<int> W){
    bool ok=false;
    bool ok2=false;
    bool ok3=false;
    for(int i=0;i<M;i++){
        if(X[i]%2){
            ok=true;
        }
        if(Y[i]!=0){
            ok2=true;
        }
        if(X[i]>1){
            cout << i << "\n";
            ok3=true;
        }
        a[X[i]]=W[i];
        if(X[i]==0){
            b[Y[i]]=W[i];
        }
        else{
            d[Y[i]]=W[i];
        }
    }
    if(!ok){
        ll res=0;
        for(int i=0;i<M;i++){
            res+=W[i];
        }
        return res;
    }
    if(!ok2){
        ll res=0;
        ll dp[N][2];
        dp[0][0]=dp[0][1]=0;
        dp[1][0]=a[1];
        dp[1][1]=a[0];
        for(int i=2;i<N;i++){
            dp[i][0]=dp[i-1][0];
            dp[i][1]=dp[i-1][1];
            dp[i][0]=max(dp[i][0],dp[i-1][1]+a[i]);
            dp[i][1]=max(dp[i][1],max(dp[i-2][0],dp[i-2][1])+a[i-1]);
        }
        return max(dp[N-1][0],dp[N-1][1]);
    }
    if(!ok3){
        for(int i=1;i<N;i++){
            b[i]+=b[i-1];
            d[i]+=d[i-1];
        }
        ll res=max(b[N-1],d[N-1]);
        if(N>2){
            for(int i=0;i<N;i++){
                res=max(res,b[i]+d[N-1]-d[i]);
            }
        }
        return res;
    }
    return 0;
}

Compilation message

fish.cpp: In function 'long long int max_weights(int, int, std::vector<int>, std::vector<int>, std::vector<int>)':
fish.cpp:81:12: warning: unused variable 'res' [-Wunused-variable]
   81 |         ll res=0;
      |            ^~~
# Verdict Execution time Memory Grader output
1 Correct 21 ms 2900 KB Output is correct
2 Correct 28 ms 3412 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Incorrect 110 ms 10092 KB Possible tampering with the output
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 50 ms 8336 KB Output is correct
3 Correct 60 ms 10064 KB Output is correct
4 Correct 24 ms 4320 KB Output is correct
5 Correct 27 ms 5184 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 308 KB Output is correct
12 Correct 25 ms 4964 KB Output is correct
13 Correct 29 ms 5956 KB Output is correct
14 Correct 28 ms 5068 KB Output is correct
15 Correct 30 ms 5572 KB Output is correct
16 Correct 27 ms 4980 KB Output is correct
17 Correct 27 ms 5464 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 224 KB Output is correct
2 Incorrect 2 ms 1888 KB Possible tampering with the output
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 224 KB Possible tampering with the output
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 224 KB Possible tampering with the output
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 224 KB Possible tampering with the output
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 224 KB Output is correct
2 Incorrect 2 ms 1888 KB Possible tampering with the output
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 21 ms 2900 KB Output is correct
2 Correct 28 ms 3412 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Incorrect 110 ms 10092 KB Possible tampering with the output
6 Halted 0 ms 0 KB -