Submission #630506

# Submission time Handle Problem Language Result Execution time Memory
630506 2022-08-16T12:41:52 Z CSQ31 Catfish Farm (IOI22_fish) C++17
0 / 100
545 ms 367260 KB
#include "fish.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int f[3001][3001];
ll dp[2][3001][3001];
//0 -> previous is lower
//1 -> previous is higher
const ll INF = -1e15;
long long max_weights(int n, int m, vector<int> X, vector<int> Y,vector<int> W) {
	for(int i=0;i<m;i++){
		X[i]++;
		Y[i]++;
		f[X[i]][Y[i]] = W[i];
	}
	for(int i=0;i<=n;i++){
		for(int j=0;j<=n;j++)dp[0][i][j] = dp[1][i][j] = INF;	
	}
	dp[0][0][0] = 0;
	for(int i=1;i<=n;i++){
		ll mx = INF;
		ll sum = 0;
		for(int j=0;j<=n;j++){
			sum+=f[i-1][j];
			mx = max(mx,dp[0][i-1][j] - sum);
			dp[0][i][j] = max(dp[0][i][j],mx+sum);
		}
		mx = INF;
		sum = 0;
		for(int j=0;j<=n;j++)sum+=f[i][j];
		for(int j=n;j>=0;j--){
			mx = max(dp[0][i-1][j]+sum,mx);
			mx = max(dp[1][i-1][j]+sum,mx);
			dp[1][i][j] = max(dp[1][i][j],mx - sum);
			sum-=f[i][j];
		}
	}
  ll ans = 0;
  for(int i=0;i<=n;i++){
	  ans = max(ans,dp[0][n][i]);
	  ans = max(ans,dp[1][n][i]);
  }
  return ans;
}
# Verdict Execution time Memory Grader output
1 Runtime error 527 ms 362448 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Runtime error 544 ms 367260 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 545 ms 357708 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 0 ms 352 KB Output is correct
7 Correct 0 ms 352 KB Output is correct
8 Correct 0 ms 352 KB Output is correct
9 Incorrect 2 ms 2400 KB 1st lines differ - on the 1st token, expected: '216624184325', found: '7818664569'
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 0 ms 352 KB Output is correct
7 Correct 0 ms 352 KB Output is correct
8 Correct 0 ms 352 KB Output is correct
9 Incorrect 2 ms 2400 KB 1st lines differ - on the 1st token, expected: '216624184325', found: '7818664569'
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 0 ms 352 KB Output is correct
7 Correct 0 ms 352 KB Output is correct
8 Correct 0 ms 352 KB Output is correct
9 Incorrect 2 ms 2400 KB 1st lines differ - on the 1st token, expected: '216624184325', found: '7818664569'
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 545 ms 357708 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 527 ms 362448 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -