답안 #1063066

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1063066 2024-08-17T13:50:52 Z jamjanek 카니발 티켓 (IOI20_tickets) C++14
11 / 100
1 ms 856 KB
#include "tickets.h"
#include <bits/stdc++.h>
using namespace std;


long long find_maximum(int k, std::vector<std::vector<int>> x) {
	int n = x.size();
	int m = x[0].size();
	int i, j;

	vector<vector<int>>answer = x;
	for(i=0;i<n;i++)
		for(j=0;j<m;j++)
			answer[i][j] = -1;

	long long wynik = 0;
	priority_queue<pair<long long, pair<int, int>>>kolejka;
	vector<set<int>>dodatnie(n), ujemne(n);

	for(i=0;i<n;i++){
		for(j=m-k;j<m;j++){
			wynik+=x[i][j];
			dodatnie[i].insert(j);
		}
		kolejka.push({-(long long)x[i][m-k]-x[i][0], {i, 0}});
	}
//	int dl = m-k;
	for(int minus=0;minus<k*n/2;minus++){
		i = kolejka.top().second.first;
		j = kolejka.top().second.second;
		wynik+=kolejka.top().first;
		kolejka.pop();
		ujemne[i].insert(j);
		j++;
		dodatnie[i].erase(j+m-k);
		if(j<k)
			kolejka.push({-(long long)x[i][m-k+j]-x[i][j], {i,j}});
	}
//	exit(0);
	//0011111
	 //1111100
	int bilans = 0;
	for(i=0;i<k;i++){
		for(j=0;j<n;j++){
			if(dodatnie[j].size()>ujemne[j].size() || (dodatnie[j].size()==ujemne[j].size() && bilans>=0)){
				auto it = *dodatnie[j].begin();
				answer[j][it] = i;
				bilans++;
				dodatnie[j].erase(it);
			}
			else{
				auto it = *ujemne[j].begin();
				answer[j][it] = i;
				bilans--;
				ujemne[j].erase(it);				
			}
		}
	}
	

	allocate_tickets(answer);
	return wynik;
	
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 856 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB Contestant returned 803235448 but the tickets gives a total value of 860858182
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB There is no ticket of color 3 on day 1
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB There is no ticket of color 0 on day 0
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB There is no ticket of color 0 on day 0
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB There is no ticket of color 0 on day 0
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 856 KB Output is correct
7 Incorrect 0 ms 348 KB Contestant returned 803235448 but the tickets gives a total value of 860858182
8 Halted 0 ms 0 KB -