Submission #660739

# Submission time Handle Problem Language Result Execution time Memory
660739 2022-11-23T06:16:16 Z mychecksedad Catfish Farm (IOI22_fish) C++17
3 / 100
86 ms 7280 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define pb push_back
const int S = 1e5;


ll dp[S][2];
long long max_weights(int n, int m, std::vector<int> x, std::vector<int> y, std::vector<int> w){  
    bool case1 = 1, case2 = 1, case3 = 1;
    for(int i = 0; i < m; ++i){
        if(x[i] % 2) case1 = 0;
        if(x[i] > 1) case2 = 0;
        if(y[i] != 0) case3 = 0;
    }
    if(case1){
        ll ans = 0;
        for(int i = 0; i < m; ++i) ans += w[i];
        return ans;
    }
    if(case2){
        ll ans1 = 0, ans2 = 0;

        for(int i = 0; i < m; ++i) if(x[i] == 0) ans1 += w[i]; else ans2 += w[i];

        return max(ans1, ans2);
    }
    if(case3){
        for(int i = 0; i <= n; ++i){
            dp[i][0] = dp[i][1] = 0;
        }
        vector<int> v(n+5); 
        for(int i = 0; i < n; ++i) v[x[i]] = w[i];
        for(int i = 1; i <= n; ++i){
            dp[i][0] = max(dp[i - 1][0], dp[i - 1][1]);
            dp[i][1] = v[i + 1];
            if(i>2){
                dp[i][1] += max({dp[i - 2][0] + v[i - 1], dp[i - 2][1], dp[i - 1][1]});
            }
        }
        return max(dp[n][0], dp[n][1]);
    }
    return -1;
}   
# Verdict Execution time Memory Grader output
1 Correct 21 ms 2132 KB Output is correct
2 Correct 27 ms 2644 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 86 ms 7244 KB Output is correct
6 Correct 86 ms 7280 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB 1st lines differ - on the 1st token, expected: '2', found: '1'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Runtime error 4 ms 4376 KB Execution killed with signal 11
3 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: '-1'
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: '-1'
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: '-1'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Runtime error 4 ms 4376 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 21 ms 2132 KB Output is correct
2 Correct 27 ms 2644 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 86 ms 7244 KB Output is correct
6 Correct 86 ms 7280 KB Output is correct
7 Incorrect 0 ms 212 KB 1st lines differ - on the 1st token, expected: '2', found: '1'
8 Halted 0 ms 0 KB -