Submission #1050724

# Submission time Handle Problem Language Result Execution time Memory
1050724 2024-08-09T13:28:48 Z TahirAliyev Carnival Tickets (IOI20_tickets) C++17
0 / 100
1 ms 348 KB
#include "tickets.h"
#include <bits/stdc++.h>
using namespace std;

#define pii pair<int, int>
#define ll long long

ll find_maximum(int k, std::vector<std::vector<int>> x) {
	int n = x.size();
	int m = x[0].size();
	vector<vector<int>> res;
	res.resize(n);
	for(int i = 0; i < n; i++) res[i].resize(m, -1);
	vector<int> l(n, 0), r(n, m - 1);
	ll ans = 0;
	priority_queue<pii> q;
	vector<int> pre(n, k), suf(n, 0);
	for(int i = 0; i < n; i++){
		int sum = 0;
		for(int j = 0; j < k; j++){
			sum -= x[i][j];
		}
		q.push({x[i][k - 1] + x[i][m - 1], i});
	}
	for(int z = 0; z < k * n / 2; z++){
		pii a = q.top();
		ans += a.first;
		pre[a.second]--;
		suf[a.second]++;
		if(suf[a.second] == k) continue;
		q.push({x[a.second][m - suf[a.second] - 1] - x[a.second][pre[a.second]], a.second});
	}
	while(q.size()) q.pop();
	for(int r = 0; r < k; r++){
		vector<pii> v;
		for(int i = 0; i < n; i++){
			v.push_back({suf[i], i});
		}
		sort(v.begin(), v.end());
		for(int i = 0; i < n / 2; i++){
			res[v[i].second][m - v[i].first] = r;  
			suf[v[i].second]--;
		}
		for(int i = n / 2; i < n; i++){
			res[v[i].second][pre[v[i].second] - 1] = r;
			pre[v[i].second]--;
		}
	}
	allocate_tickets(res);
	return ans;
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB There is no ticket of color 0 on day 0
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB There is no ticket of color 0 on day 0
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 344 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 0 ms 348 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 348 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 348 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB There is no ticket of color 0 on day 0
2 Halted 0 ms 0 KB -