Submission #709832

# Submission time Handle Problem Language Result Execution time Memory
709832 2023-03-14T15:39:47 Z myrcella Catfish Farm (IOI22_fish) C++17
52 / 100
436 ms 300496 KB
//by szh
#include<bits/stdc++.h>
#include "fish.h"

using namespace std;

#define fi first
#define se second
#define pii pair<int,int>
#define pll pair<long long,long long>
#define pb push_back
#define debug(x) cerr<<#x<<"="<<x<<endl
#define pq priority_queue
#define inf 0x3f
#define rep(i,a,b) for (int i=a;i<(b);i++)
#define MP make_pair
#define SZ(x) (int(x.size()))
#define ll long long
#define mod 1000000007
#define ALL(x) x.begin(),x.end()
void inc(int &a,int b) {a=(a+b)%mod;}
void dec(int &a,int b) {a=(a-b+mod)%mod;}
int lowbit(int x) {return x&(-x);}
ll p0w(ll base,ll p) {ll ret=1;while(p>0){if (p%2ll==1ll) ret=ret*base%mod;base=base*base%mod;p/=2ll;}return ret;}

const int maxn = 3010;
ll dp[maxn][maxn][2];
int y[maxn*maxn];
int w[maxn][maxn];
int xmax,ymax;

long long max_weights(int N, int M, std::vector<int> X, std::vector<int> Y,std::vector<int> W) {
	rep(i,0,M) {
		y[i] = Y[i];
		y[i]++;
		w[X[i]][y[i]]=W[i];
		xmax = max(X[i],xmax);
		ymax = max(y[i],ymax);
	}
	ll ans = 0;
	rep(i,0,N) rep(j,1,N+1) dp[i][j][0] = dp[i][j][1] = -1e18;
	dp[0][0][0] = dp[0][N][1] = 0;
	rep(i,1,N) {
		//increasing
		dp[i][0][0] = dp[i-1][0][0];
		rep(j,1,N+1) {
			dp[i][j][0] = max(dp[i-1][j][0],dp[i][j-1][0] + w[i-1][j]);
		}
		dp[i][N][1] = dp[i-1][N][1];
		for (int j = N-1;j>=0;j--) {
			dp[i][j][1] = max(dp[i-1][j][1],dp[i][j+1][1] + w[i][j+1]);
		}
		dp[i][0][0] = max(dp[i][0][0],dp[i-1][0][1]);
		ll tmp = 0;
		rep(j,1,N+1) tmp += w[i-1][j];
		if (i-2>=0) dp[i][N][1] = max(dp[i][N][1],dp[i-2][N][1]+tmp);
		dp[i][N][0] = dp[i][N][1] = max(dp[i][N][0],dp[i][N][1]);
		rep(j,0,N+1) {
			ans = max(ans,max(dp[i][j][0],dp[i][j][1]));
//			cout<<i<<" "<<j<<" "<<dp[i][j][0]<<" "<<dp[i][j][1];debug(w[i][1]);
		}
	}
  return ans;
}
# Verdict Execution time Memory Grader output
1 Runtime error 436 ms 290884 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 312 KB Output is correct
2 Runtime error 414 ms 300496 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 393 ms 288016 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 308 KB Output is correct
7 Correct 1 ms 312 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 2 ms 1876 KB Output is correct
10 Correct 4 ms 4216 KB Output is correct
11 Correct 2 ms 1876 KB Output is correct
12 Correct 3 ms 4160 KB Output is correct
13 Correct 1 ms 980 KB Output is correct
14 Correct 4 ms 4180 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 308 KB Output is correct
7 Correct 1 ms 312 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 2 ms 1876 KB Output is correct
10 Correct 4 ms 4216 KB Output is correct
11 Correct 2 ms 1876 KB Output is correct
12 Correct 3 ms 4160 KB Output is correct
13 Correct 1 ms 980 KB Output is correct
14 Correct 4 ms 4180 KB Output is correct
15 Correct 3 ms 4172 KB Output is correct
16 Correct 2 ms 884 KB Output is correct
17 Correct 15 ms 5968 KB Output is correct
18 Correct 15 ms 5824 KB Output is correct
19 Correct 16 ms 6196 KB Output is correct
20 Correct 16 ms 6324 KB Output is correct
21 Correct 16 ms 6228 KB Output is correct
22 Correct 30 ms 8400 KB Output is correct
23 Correct 6 ms 4820 KB Output is correct
24 Correct 12 ms 5716 KB Output is correct
25 Correct 4 ms 4180 KB Output is correct
26 Correct 6 ms 4564 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 308 KB Output is correct
7 Correct 1 ms 312 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 2 ms 1876 KB Output is correct
10 Correct 4 ms 4216 KB Output is correct
11 Correct 2 ms 1876 KB Output is correct
12 Correct 3 ms 4160 KB Output is correct
13 Correct 1 ms 980 KB Output is correct
14 Correct 4 ms 4180 KB Output is correct
15 Correct 3 ms 4172 KB Output is correct
16 Correct 2 ms 884 KB Output is correct
17 Correct 15 ms 5968 KB Output is correct
18 Correct 15 ms 5824 KB Output is correct
19 Correct 16 ms 6196 KB Output is correct
20 Correct 16 ms 6324 KB Output is correct
21 Correct 16 ms 6228 KB Output is correct
22 Correct 30 ms 8400 KB Output is correct
23 Correct 6 ms 4820 KB Output is correct
24 Correct 12 ms 5716 KB Output is correct
25 Correct 4 ms 4180 KB Output is correct
26 Correct 6 ms 4564 KB Output is correct
27 Correct 117 ms 153824 KB Output is correct
28 Correct 71 ms 24324 KB Output is correct
29 Correct 201 ms 157032 KB Output is correct
30 Correct 205 ms 184268 KB Output is correct
31 Correct 212 ms 184796 KB Output is correct
32 Correct 87 ms 23792 KB Output is correct
33 Correct 203 ms 190808 KB Output is correct
34 Correct 206 ms 190816 KB Output is correct
35 Correct 155 ms 160332 KB Output is correct
36 Correct 207 ms 165848 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 393 ms 288016 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 436 ms 290884 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -