답안 #866558

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
866558 2023-10-26T11:43:11 Z vjudge1 메기 농장 (IOI22_fish) C++17
3 / 100
1000 ms 23144 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;

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]});
	}
	vector<ll> dp[MAXN];
	for (int i = 0; i <= n; i++){
		pos[i].push_back({MAXN, 0});
		sort(all(pos[i]));
		dp[i].resize(sz(pos[i]), 0ll);
	}
	for (int i = 1; i <= n; i++){
		for (int j = 0; j < sz(dp[i]); j++){
			ll& me = dp[i][j];
			ll cnt = 0;
			for (int k = sz(dp[i - 1]) - 1; k >= 0; k--){
				if (pos[i - 1][k].F <= pos[i][j].F - 1) cnt += pos[i - 1][k].S;
				me = max(me, cnt + dp[i-1][k]);
			}
			if (i == n){
				int p = sz(pos[i]) - 1;
				ll cnt2 = 0;
				cnt = 0;
				for (int k = j; k < sz(pos[i]); k++) cnt2 += pos[i][k].S;

				for (int k = sz(dp[i - 1]) - 1; k >= 0; k--){

					if (pos[i - 1][k].F <= pos[i][j].F - 1) cnt += pos[i - 1][k].S;
					while (p >= j && pos[i - 1][k].F - 1 < pos[i][p].F){
						cnt2 -= pos[i][p].S;
						p--;
					}

					me = max(me, cnt2 + cnt + dp[i-1][k]);
				}
			}
		}
	}
	ll ans = 0;
	for (auto it : dp[n]){
		ans = max(ans, it);
	}
	return ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 38 ms 13768 KB Output is correct
2 Correct 43 ms 15300 KB Output is correct
3 Correct 13 ms 11356 KB Output is correct
4 Correct 14 ms 11352 KB Output is correct
5 Correct 104 ms 22984 KB Output is correct
6 Correct 115 ms 23144 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 4956 KB Output is correct
2 Execution timed out 1096 ms 17084 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 12 ms 11356 KB Output is correct
2 Correct 12 ms 11292 KB Output is correct
3 Incorrect 35 ms 11900 KB 1st lines differ - on the 1st token, expected: '21261825233649', found: '16359027219341'
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 4952 KB Output is correct
2 Correct 3 ms 4956 KB Output is correct
3 Correct 3 ms 4956 KB Output is correct
4 Correct 3 ms 4956 KB Output is correct
5 Correct 4 ms 4956 KB Output is correct
6 Correct 4 ms 4956 KB Output is correct
7 Correct 3 ms 4956 KB Output is correct
8 Incorrect 3 ms 5080 KB 1st lines differ - on the 1st token, expected: '2', found: '1'
9 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 4952 KB Output is correct
2 Correct 3 ms 4956 KB Output is correct
3 Correct 3 ms 4956 KB Output is correct
4 Correct 3 ms 4956 KB Output is correct
5 Correct 4 ms 4956 KB Output is correct
6 Correct 4 ms 4956 KB Output is correct
7 Correct 3 ms 4956 KB Output is correct
8 Incorrect 3 ms 5080 KB 1st lines differ - on the 1st token, expected: '2', found: '1'
9 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 4952 KB Output is correct
2 Correct 3 ms 4956 KB Output is correct
3 Correct 3 ms 4956 KB Output is correct
4 Correct 3 ms 4956 KB Output is correct
5 Correct 4 ms 4956 KB Output is correct
6 Correct 4 ms 4956 KB Output is correct
7 Correct 3 ms 4956 KB Output is correct
8 Incorrect 3 ms 5080 KB 1st lines differ - on the 1st token, expected: '2', found: '1'
9 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 12 ms 11356 KB Output is correct
2 Correct 12 ms 11292 KB Output is correct
3 Incorrect 35 ms 11900 KB 1st lines differ - on the 1st token, expected: '21261825233649', found: '16359027219341'
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 38 ms 13768 KB Output is correct
2 Correct 43 ms 15300 KB Output is correct
3 Correct 13 ms 11356 KB Output is correct
4 Correct 14 ms 11352 KB Output is correct
5 Correct 104 ms 22984 KB Output is correct
6 Correct 115 ms 23144 KB Output is correct
7 Correct 3 ms 4956 KB Output is correct
8 Execution timed out 1096 ms 17084 KB Time limit exceeded
9 Halted 0 ms 0 KB -