Submission #715982

# Submission time Handle Problem Language Result Execution time Memory
715982 2023-03-28T16:59:10 Z Huseyn123 Catfish Farm (IOI22_fish) C++17
12 / 100
99 ms 8828 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){
            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:80:12: warning: unused variable 'res' [-Wunused-variable]
   80 |         ll res=0;
      |            ^~~
# Verdict Execution time Memory Grader output
1 Correct 22 ms 2892 KB Output is correct
2 Correct 29 ms 3388 KB Output is correct
3 Correct 0 ms 232 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 96 ms 8044 KB Output is correct
6 Correct 99 ms 8828 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB 1st lines differ - on the 1st token, expected: '2', found: '0'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 2 ms 1876 KB Output is correct
3 Correct 16 ms 3640 KB Output is correct
4 Correct 13 ms 3412 KB Output is correct
5 Correct 32 ms 5164 KB Output is correct
6 Correct 32 ms 5160 KB Output is correct
7 Correct 29 ms 5148 KB Output is correct
8 Correct 33 ms 5136 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB 1st lines differ - on the 1st token, expected: '3', found: '0'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB 1st lines differ - on the 1st token, expected: '3', found: '0'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB 1st lines differ - on the 1st token, expected: '3', found: '0'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 2 ms 1876 KB Output is correct
3 Correct 16 ms 3640 KB Output is correct
4 Correct 13 ms 3412 KB Output is correct
5 Correct 32 ms 5164 KB Output is correct
6 Correct 32 ms 5160 KB Output is correct
7 Correct 29 ms 5148 KB Output is correct
8 Correct 33 ms 5136 KB Output is correct
9 Incorrect 25 ms 4368 KB 1st lines differ - on the 1st token, expected: '99999', found: '0'
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 22 ms 2892 KB Output is correct
2 Correct 29 ms 3388 KB Output is correct
3 Correct 0 ms 232 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 96 ms 8044 KB Output is correct
6 Correct 99 ms 8828 KB Output is correct
7 Incorrect 1 ms 212 KB 1st lines differ - on the 1st token, expected: '2', found: '0'
8 Halted 0 ms 0 KB -