제출 #866541

#제출 시각아이디문제언어결과실행 시간메모리
866541vjudge1메기 농장 (IOI22_fish)C++17
6 / 100
91 ms14696 KiB
#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;
}

컴파일 시 표준 에러 (stderr) 메시지

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;
      |     ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...