답안 #673734

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
673734 2022-12-21T20:44:24 Z US3RN4M3 메기 농장 (IOI22_fish) C++17
18 / 100
122 ms 17472 KB
#include"fish.h"
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int mx = 100105;
vector<pair<int, int>> fish[mx];
ll bests[mx];
ll maxs[mx];
ll max_weights(int N, int M, vector<int> X, vector<int> Y, vector<int> W) {
	for(int i = 0; i < M; i++) {
		fish[X[i] + 10].push_back({Y[i], W[i]});
	}
	for(int i = 0; i < mx; i++) {
		fish[i].push_back({N + 10, 0});
	}
	for(int i = 10; i < N + 10; i++) {
		sort(fish[i].begin(), fish[i].end());
		if(i < 10) continue;
		int cur = i;
		//if(i > 3)
		//bests[i - 3] = max(bests[i - 3], bests[i - 4]);
		//bests[i - 2] = max(bests[i - 2], bests[i - 3]);
		/* double dock */
		if(i != 10) {
			/* i am full */
			{
				ll cur_sum = 0;
				for(auto [pos, val] : fish[i - 1]) cur_sum += val;
				for(auto [pos, val] : fish[i + 1]) cur_sum += val;
				ll best_sum = cur_sum;
				int pp_idx = 0;
				int p_idx = 0;
				while(p_idx != fish[cur - 1].size()) {
					while(pp_idx != fish[cur - 2].size() && fish[cur - 2][pp_idx].first < fish[cur - 1][p_idx].first) {
						cur_sum += fish[cur - 2][pp_idx].second;
						best_sum = max(best_sum, cur_sum);
						pp_idx++;
					}
					cur_sum -= fish[cur - 1][p_idx].second;
					p_idx++;
				}
				//cout << i - 10 << ",1: " << cur_sum << endl;
				bests[i] = max(bests[i], maxs[i - 4] + best_sum);
			}
			//cout << bests[i] << " ";

			/* prev is full */
			{
				ll cur_sum = 0;
				for(auto [pos, val] : fish[i - 2]) cur_sum += val;
				for(auto [pos, val] : fish[i]) cur_sum += val;
				ll best_sum = cur_sum;
				int c_idx = 0;
				int n_idx = 0;
				while(c_idx != fish[cur].size()) {
					while(n_idx != fish[cur + 1].size() && fish[cur + 1][n_idx].first < fish[cur][c_idx].first) {
						cur_sum += fish[cur + 1][n_idx].second;
						best_sum = max(best_sum, cur_sum);
						n_idx++;
					}
					cur_sum -= fish[cur][c_idx].second;
					c_idx++;
				}
				//cout << i - 10 << ",2: " << cur_sum << endl;
				bests[i] = max(bests[i], maxs[i - 4] + best_sum);
			}
			//cout << bests[i] << " ";
		}
		/* single dock */
		{
			ll cur_sum = 0;
			for(auto [pos, val] : fish[i + 1]) cur_sum += val;
			bests[i] = max(bests[i], maxs[i - 2] + cur_sum);
			for(auto [pos, val] : fish[i - 1]) cur_sum += val;
			bests[i] = max(bests[i], maxs[i - 3] + cur_sum);
			//cout << i - 10 << ",3: " << cur_sum << endl;
		}
		//cout << bests[i] << endl;
		maxs[i] = max(bests[i], maxs[i - 1]);
	}
	//for(int i = 10; i < N + 10; i++) cout << bests[i] << " ";
	return bests[N + 9];
}

Compilation message

fish.cpp: In function 'll max_weights(int, int, std::vector<int>, std::vector<int>, std::vector<int>)':
fish.cpp:33:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   33 |     while(p_idx != fish[cur - 1].size()) {
      |           ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
fish.cpp:34:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   34 |      while(pp_idx != fish[cur - 2].size() && fish[cur - 2][pp_idx].first < fish[cur - 1][p_idx].first) {
      |            ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
fish.cpp:55:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   55 |     while(c_idx != fish[cur].size()) {
      |           ~~~~~~^~~~~~~~~~~~~~~~~~~
fish.cpp:56:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   56 |      while(n_idx != fish[cur + 1].size() && fish[cur + 1][n_idx].first < fish[cur][c_idx].first) {
      |            ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 37 ms 9664 KB Output is correct
2 Correct 44 ms 10480 KB Output is correct
3 Correct 8 ms 7248 KB Output is correct
4 Correct 8 ms 7252 KB Output is correct
5 Correct 122 ms 16640 KB Output is correct
6 Correct 120 ms 17472 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 5716 KB Output is correct
2 Correct 66 ms 12268 KB Output is correct
3 Correct 78 ms 13524 KB Output is correct
4 Correct 38 ms 9616 KB Output is correct
5 Correct 43 ms 10468 KB Output is correct
6 Correct 6 ms 5740 KB Output is correct
7 Correct 6 ms 5716 KB Output is correct
8 Correct 6 ms 5676 KB Output is correct
9 Correct 6 ms 5716 KB Output is correct
10 Correct 8 ms 7272 KB Output is correct
11 Correct 8 ms 7252 KB Output is correct
12 Correct 35 ms 9632 KB Output is correct
13 Correct 43 ms 10480 KB Output is correct
14 Correct 36 ms 9696 KB Output is correct
15 Correct 41 ms 10176 KB Output is correct
16 Correct 36 ms 9756 KB Output is correct
17 Correct 42 ms 10152 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 7252 KB Output is correct
2 Correct 8 ms 7252 KB Output is correct
3 Correct 27 ms 8368 KB Output is correct
4 Correct 20 ms 8140 KB Output is correct
5 Correct 41 ms 9700 KB Output is correct
6 Correct 37 ms 9684 KB Output is correct
7 Correct 50 ms 9720 KB Output is correct
8 Correct 40 ms 9596 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 6 ms 5716 KB 1st lines differ - on the 1st token, expected: '3', found: '2'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 6 ms 5716 KB 1st lines differ - on the 1st token, expected: '3', found: '2'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 6 ms 5716 KB 1st lines differ - on the 1st token, expected: '3', found: '2'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 7252 KB Output is correct
2 Correct 8 ms 7252 KB Output is correct
3 Correct 27 ms 8368 KB Output is correct
4 Correct 20 ms 8140 KB Output is correct
5 Correct 41 ms 9700 KB Output is correct
6 Correct 37 ms 9684 KB Output is correct
7 Correct 50 ms 9720 KB Output is correct
8 Correct 40 ms 9596 KB Output is correct
9 Incorrect 39 ms 9596 KB 1st lines differ - on the 1st token, expected: '99999', found: '74999'
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 37 ms 9664 KB Output is correct
2 Correct 44 ms 10480 KB Output is correct
3 Correct 8 ms 7248 KB Output is correct
4 Correct 8 ms 7252 KB Output is correct
5 Correct 122 ms 16640 KB Output is correct
6 Correct 120 ms 17472 KB Output is correct
7 Correct 5 ms 5716 KB Output is correct
8 Correct 66 ms 12268 KB Output is correct
9 Correct 78 ms 13524 KB Output is correct
10 Correct 38 ms 9616 KB Output is correct
11 Correct 43 ms 10468 KB Output is correct
12 Correct 6 ms 5740 KB Output is correct
13 Correct 6 ms 5716 KB Output is correct
14 Correct 6 ms 5676 KB Output is correct
15 Correct 6 ms 5716 KB Output is correct
16 Correct 8 ms 7272 KB Output is correct
17 Correct 8 ms 7252 KB Output is correct
18 Correct 35 ms 9632 KB Output is correct
19 Correct 43 ms 10480 KB Output is correct
20 Correct 36 ms 9696 KB Output is correct
21 Correct 41 ms 10176 KB Output is correct
22 Correct 36 ms 9756 KB Output is correct
23 Correct 42 ms 10152 KB Output is correct
24 Correct 8 ms 7252 KB Output is correct
25 Correct 8 ms 7252 KB Output is correct
26 Correct 27 ms 8368 KB Output is correct
27 Correct 20 ms 8140 KB Output is correct
28 Correct 41 ms 9700 KB Output is correct
29 Correct 37 ms 9684 KB Output is correct
30 Correct 50 ms 9720 KB Output is correct
31 Correct 40 ms 9596 KB Output is correct
32 Incorrect 6 ms 5716 KB 1st lines differ - on the 1st token, expected: '3', found: '2'
33 Halted 0 ms 0 KB -