Submission #644403

# Submission time Handle Problem Language Result Execution time Memory
644403 2022-09-24T15:37:19 Z Dextar Catfish Farm (IOI22_fish) C++17
0 / 100
1000 ms 2097152 KB
#include <cstdio>
#ifdef DEBUG
    #define D(X) X
#else
    #define D(X)
#endif
#include <bits/stdc++.h>
#define F first
#define S second
#define ll long long
#define pi 3.14159265359
#define pub push_back
#define pob pop_back
//#include <fish.h>

using namespace std;

const int INF = 1000 * 1000 * 1000;
const int mod = 1000 * 1000 * 1000 + 7;

ll max_weights(int n, int m, vector<int> x, vector<int> y, vector<int> w)
    {
        vector<vector<ll>> cnt(n, vector<ll>(n+1, 0));
        for(int i=0; i<m; i++) {
            cnt[x[i]][y[i]+1] = w[i];
        }
        for(int j=0; j<n; j++) {
            for(int i=1; i<=n; i++) {
                cnt[j][i] += cnt[j][i-1];
            }
        }
        vector<vector<int>> fish(n);
        for(int i=0; i<m; i++) {
            fish[x[i]].pub(y[i]);
        }

        vector<ll> dp(n+1);
        dp[n] = 0;
        vector<vector<ll>> dp2(3, vector<ll>(n+1, 0)), mx1(3, vector<ll>(n+1, 0)), mx2(3, vector<ll>(n+1, 0));
        int bin = 0;
        for(int i=n-1; i>=0; i--) {
            dp[i] = dp[i+1];
            if(i<n-1) {
                for(int j=0; j<=n; j++) {
                    ll cur = cnt[i][j];
                    cur += max(mx1[(bin-2+3)%3][j], mx2[(bin-2+3)%3][j] - cnt[i+1][j]);
                    dp[i] = max(dp[i], cur);
                    dp[i] = max(dp[i], dp[i+2] + cnt[i+1][n] - cnt[i+1][j]);
                }
            }
            if(i==0) {
                break;
            }
            for(int j=0; j<=n; j++) {
                dp2[bin][j] = max(mx1[(bin-1+3)%3][j], mx2[(bin-1+3)%3][j]); //if(i==n-2) cout<<dp2[bin][j]<<endl;
            }
            mx1[bin][0] = dp2[bin][0];
            for(int j=1; j<=n; j++) {
                mx1[bin][j] = max(mx1[bin][j-1], dp2[bin][j]);   //if(i==n-1) cout<<mx1[bin][j]<<endl;
            }
            mx2[bin][n] = 0;
            for(int j=n-1; j>=0; j--) {
                mx2[bin][j] = max(mx2[bin][j+1], dp2[bin][j] + cnt[i-1][j]);   //if(i==n-1) cout<<mx2[bin][j]<<endl;
            }
            bin = (bin+1)%3;   //cout<<dp[i]<<endl;
        }
        return dp[0];
    }
# Verdict Execution time Memory Grader output
1 Execution timed out 1182 ms 1943104 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Runtime error 903 ms 2097152 KB Execution killed with signal 9
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 771 ms 2097152 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 300 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 216 KB Output is correct
4 Correct 0 ms 216 KB Output is correct
5 Correct 1 ms 220 KB Output is correct
6 Correct 0 ms 220 KB Output is correct
7 Correct 1 ms 216 KB Output is correct
8 Incorrect 1 ms 224 KB 1st lines differ - on the 1st token, expected: '2', found: '1'
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 300 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 216 KB Output is correct
4 Correct 0 ms 216 KB Output is correct
5 Correct 1 ms 220 KB Output is correct
6 Correct 0 ms 220 KB Output is correct
7 Correct 1 ms 216 KB Output is correct
8 Incorrect 1 ms 224 KB 1st lines differ - on the 1st token, expected: '2', found: '1'
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 300 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 216 KB Output is correct
4 Correct 0 ms 216 KB Output is correct
5 Correct 1 ms 220 KB Output is correct
6 Correct 0 ms 220 KB Output is correct
7 Correct 1 ms 216 KB Output is correct
8 Incorrect 1 ms 224 KB 1st lines differ - on the 1st token, expected: '2', found: '1'
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 771 ms 2097152 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1182 ms 1943104 KB Time limit exceeded
2 Halted 0 ms 0 KB -