답안 #838729

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
838729 2023-08-27T16:15:15 Z mychecksedad 카니발 티켓 (IOI20_tickets) C++17
27 / 100
383 ms 51360 KB
// #include<tickets.h>
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define mod1 (1000000000+7)
#define mod (998244353)
#define pb push_back
#define all(x) x.begin(), x.end()
#define en cout << '\n'
const int N = 1e6+100, M = 1e5+10, K = 18;


void allocate_tickets( std::vector<std::vector<int>> _x);
long long find_maximum(int k, vector<vector<int>> d){
	ll ans = 0;
	int n = d.size(), m = d[0].size();
	vector<vector<int>> A(n, vector<int>(m, -1));
	vector<array<ll, 2>> a;
	set<array<int, 3>> big, small;
	vector<int> H(n), L(n);

	for(int i = 0; i < n; ++i){
		H[i] = k;
		for(int j = m - k; j < m; ++j){
			ans += d[i][j];
			a.pb({-(d[i][j] + d[i][j - (m - k)]), i});
		}
	}

	sort(all(a), greater<array<ll, 2>>());

	for(int i = 0; i < n*k/2; ++i){
		ans += a[i][0];
		H[a[i][1]]--;
	}	
	for(int i = 0; i < n; ++i) L[i] = k - H[i];
	
	for(int i = 0; i < n; ++i){
		if(H[i] > 0)
			big.insert({-d[i][m - k], i, m - k});
		if(L[i] > 0)
			small.insert({-d[i][0], i, 0});
	}

	for(int turn = 0; turn < k; ++turn){
		vector<bool> used(n);
		set<array<int, 3>> bt, st;
		int c = 0;
		for(auto x: big){
			if(used[x[1]] || c == n / 2){
				bt.insert(x);
				continue;
			}
			used[x[1]] = 1;
			A[x[1]][x[2]] = turn;
			H[x[1]]--;
			c++;
			if(H[x[1]] > 0)
				bt.insert({-d[x[1]][m - H[x[1]]], x[1], m - H[x[1]]});
		}
		c = 0;
		for(auto x: small){
			if(used[x[1]] || c == n / 2){
				st.insert(x);
				continue;
			}
			used[x[1]] = 1;
			A[x[1]][x[2]] = turn;
			L[x[1]]--;
			c++;
			if(L[x[1]] > 0)
				st.insert({-d[x[1]][L[x[1]]], x[1], L[x[1]]});
		}
		big.swap(bt);
		small.swap(st);
	}

	allocate_tickets(A);
	return ans;
}

# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 2 ms 848 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 2 ms 340 KB Output is correct
5 Correct 16 ms 2388 KB Output is correct
6 Correct 383 ms 51360 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 212 KB There is no ticket of color 2 on day 1
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB There is no ticket of color 1 on day 0
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 212 KB There is no ticket of color 1 on day 0
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 212 KB There is no ticket of color 1 on day 0
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 2 ms 848 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 2 ms 340 KB Output is correct
11 Correct 16 ms 2388 KB Output is correct
12 Correct 383 ms 51360 KB Output is correct
13 Incorrect 1 ms 212 KB There is no ticket of color 2 on day 1
14 Halted 0 ms 0 KB -