답안 #866541

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
866541 2023-10-26T10:44:10 Z vjudge1 메기 농장 (IOI22_fish) C++17
6 / 100
91 ms 14696 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


ll max_weights(int n, int m, vector<int> X, std::vector<int> Y, vector<int> W) {
	vector<pair<int, int>> pos[2];
	for (int i = 0; i < m; i++){
		pos[X[i]].push_back({Y[i], W[i]});
	}
	sort(all(pos[0]));
	sort(all(pos[1]));
	ll cnt0 = 0;
	for (auto [y, w] : pos[0]) cnt0 += w;
	ll cnt1 = 0;
	for (auto [y, w] : pos[1]) cnt1 += w;
	ll ans = max(cnt0, cnt1);
	ll o = ans;
	int p = 0;
	ll cnt = 0;
	if (n > 2){
		for (auto [y, w] : pos[0]){
			while (p < sz(pos[1]) && pos[1][p].F <= y){
				cnt1 -= pos[1][p].S;
				p++;
			}
			cnt += w;
			ans = max(ans, cnt + cnt1);
		}
	}
	return ans;
}

Compilation message

fish.cpp: In function 'long long int max_weights(int, int, std::vector<int>, std::vector<int>, std::vector<int>)':
fish.cpp:23:5: warning: unused variable 'o' [-Wunused-variable]
   23 |  ll o = ans;
      |     ^
# 결과 실행 시간 메모리 Grader output
1 Correct 23 ms 3284 KB Output is correct
2 Correct 29 ms 3776 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Runtime error 91 ms 14696 KB Execution killed with signal 11
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 47 ms 5828 KB Output is correct
3 Correct 59 ms 7104 KB Output is correct
4 Correct 24 ms 3272 KB Output is correct
5 Correct 29 ms 3796 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 344 KB Output is correct
12 Correct 24 ms 4704 KB Output is correct
13 Correct 29 ms 5588 KB Output is correct
14 Correct 24 ms 4608 KB Output is correct
15 Correct 27 ms 5080 KB Output is correct
16 Correct 24 ms 4556 KB Output is correct
17 Correct 26 ms 5080 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Runtime error 1 ms 348 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 348 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 348 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 348 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Runtime error 1 ms 348 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 23 ms 3284 KB Output is correct
2 Correct 29 ms 3776 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Runtime error 91 ms 14696 KB Execution killed with signal 11
6 Halted 0 ms 0 KB -