Submission #1075640

# Submission time Handle Problem Language Result Execution time Memory
1075640 2024-08-26T08:15:19 Z Sir_Ahmed_Imran Catfish Farm (IOI22_fish) C++17
35 / 100
73 ms 12452 KB
                            ///~~~LOTA~~~///
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define append push_back
#define add insert
#define nl '\n'
#define ff first
#define ss second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define all(x) (x).begin(),(x).end()
#define L0TA ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define terminator main
#define N 301
ll hs[N][N];
ll dp[N][N];
ll dp2[N][N];
ll max_weights(int n,int m,vector<int> x,vector<int> y,vector<int> w){
    for(int i=0;i<m;i++)
        hs[x[i]+1][y[i]+1]+=w[i];
    for(int i=1;i<=n;i++)
        for(int j=0;j<n;j++)
            hs[i][j+1]+=hs[i][j];
    for(int i=1;i<=n;i++)
        dp[0][i]=dp2[0][i]=-1e17;
    for(int i=1;i<=n;i++){
        for(int j=0;j<=n;j++){
            for(int k=0;k<=n;k++){
                if(j<k){
                    dp[i][j]=max(dp[i][j],dp[i-1][k]+hs[i][k]-hs[i][j]);
                    dp2[i][k]=max(dp2[i][k],dp[i-1][k]+hs[i][k]-hs[i][j]);
                }
                else{
                    dp[i][j]=max(dp[i][j],dp2[i-1][k]+hs[i-1][j]-hs[i-1][k]);
                    dp2[i][j]=max(dp2[i][j],dp2[i-1][k]+hs[i-1][j]-hs[i-1][k]);
                }
            }
            dp2[i][j]=max(dp2[i][j],dp[i-1][j]+hs[i][j]);
        }
    }
    ll ans=0;
    for(int i=0;i<=n;i++)
        ans=max(ans,max(dp[n][i],dp2[n][i]));
    return ans;
}
# Verdict Execution time Memory Grader output
1 Runtime error 19 ms 7260 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 596 KB Output is correct
2 Runtime error 39 ms 12452 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 1880 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 424 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 8 ms 1368 KB Output is correct
10 Correct 55 ms 2544 KB Output is correct
11 Correct 8 ms 1372 KB Output is correct
12 Correct 60 ms 2492 KB Output is correct
13 Correct 2 ms 856 KB Output is correct
14 Correct 58 ms 2664 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 424 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 8 ms 1368 KB Output is correct
10 Correct 55 ms 2544 KB Output is correct
11 Correct 8 ms 1372 KB Output is correct
12 Correct 60 ms 2492 KB Output is correct
13 Correct 2 ms 856 KB Output is correct
14 Correct 58 ms 2664 KB Output is correct
15 Correct 56 ms 2372 KB Output is correct
16 Correct 2 ms 860 KB Output is correct
17 Correct 63 ms 4184 KB Output is correct
18 Correct 64 ms 4280 KB Output is correct
19 Correct 63 ms 4200 KB Output is correct
20 Correct 72 ms 4276 KB Output is correct
21 Correct 64 ms 4184 KB Output is correct
22 Correct 71 ms 6068 KB Output is correct
23 Correct 58 ms 2900 KB Output is correct
24 Correct 73 ms 3668 KB Output is correct
25 Correct 59 ms 2548 KB Output is correct
26 Correct 57 ms 2636 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 424 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 8 ms 1368 KB Output is correct
10 Correct 55 ms 2544 KB Output is correct
11 Correct 8 ms 1372 KB Output is correct
12 Correct 60 ms 2492 KB Output is correct
13 Correct 2 ms 856 KB Output is correct
14 Correct 58 ms 2664 KB Output is correct
15 Correct 56 ms 2372 KB Output is correct
16 Correct 2 ms 860 KB Output is correct
17 Correct 63 ms 4184 KB Output is correct
18 Correct 64 ms 4280 KB Output is correct
19 Correct 63 ms 4200 KB Output is correct
20 Correct 72 ms 4276 KB Output is correct
21 Correct 64 ms 4184 KB Output is correct
22 Correct 71 ms 6068 KB Output is correct
23 Correct 58 ms 2900 KB Output is correct
24 Correct 73 ms 3668 KB Output is correct
25 Correct 59 ms 2548 KB Output is correct
26 Correct 57 ms 2636 KB Output is correct
27 Runtime error 1 ms 600 KB Execution killed with signal 11
28 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 1880 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 19 ms 7260 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -