Submission #866563

# Submission time Handle Problem Language Result Execution time Memory
866563 2023-10-26T12:07:21 Z vjudge1 Catfish Farm (IOI22_fish) C++17
0 / 100
27 ms 16124 KB
#include "fish.h"
#include<bits/stdc++.h>
using namespace std;
#define ll long long// !
#define sz(a) (int)a.size()
#define all(a) a.begin(),a.end()
#define F first
#define S second
const int MAXN = 1e5 + 3;

int dp[MAXN][2];
ll max_weights(int n, int m, vector<int> X, std::vector<int> Y, vector<int> W) {
	// dp[i][j], for i'th column just before the j'th element
	vector<pair<int, int>> pos[MAXN];
	for (int i = 0; i < m; i++){
		pos[X[i]+1].push_back({Y[i], W[i]});
	}
	for (int i = 1; i <= n; i++){
		if (sz(pos[i]) == 0 ) pos[i].push_back({MAXN, 0});
	}
	for (int i = 1; i <= n; i++){
		dp[i][0] = max(dp[i-1][1], dp[i-1][0]);
		dp[i][1] = dp[i-1][0]+pos[i-1][0].S;
		if (i == n){
			dp[i][0] = max(dp[i-1][1] + pos[i][0].S, dp[i-1][0]);
		}
	}
	return max(dp[n][0], dp[n][1]);
}
# Verdict Execution time Memory Grader output
1 Runtime error 27 ms 16124 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 4 ms 5212 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 8 ms 11612 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 4 ms 5212 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 4 ms 5212 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 4 ms 5212 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 8 ms 11612 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 27 ms 16124 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -