Submission #1050374

# Submission time Handle Problem Language Result Execution time Memory
1050374 2024-08-09T08:59:05 Z fuad27 Carnival Tickets (IOI20_tickets) C++17
39 / 100
440 ms 54440 KB
#include "tickets.h"
#include <bits/stdc++.h>
using namespace std;
long long find_maximum(int k, std::vector<std::vector<int>> x) {
#define int long long
	int n = x.size();
	int m = x[0].size();
	vector<pair<int,int>> s(n);
	vector<int> all, cnt(n);
	for(int i = 0;i<n;i++) {
		s[i] = pair{0, m-1};
	}
	vector<vector<int32_t>> res(n, vector<int32_t>(m, -1));

	priority_queue<pair<pair<int,int>,int>> pq;
	for(int i = 0;i<n;i++) {
			pq.push({{-x[i][m-k], -x[i][cnt[i]]}, i});
	}
	for(int _ = 0;_<(n*k)/2;_++) {
		int i = pq.top().second;
		pq.pop();
		cnt[i]++;
		if(m-k+cnt[i] < m) {
			pq.push({{-x[i][m-k+cnt[i]], -x[i][cnt[i]]}, i});
		}
	}
	long long sum=0;
	for(int _ = 0;_<k;_++) {
		vector<int> idxs(n);
		iota(idxs.begin(), idxs.end(), 0);
		sort(idxs.begin(), idxs.end(), [&](int a, int b) -> bool {
			return cnt[a] < cnt[b];
		});
		vector<int> ans;
		for(int i = 0;i<n/2;i++) {
			sum+=x[idxs[i]][s[idxs[i]].second];
			res[idxs[i]][s[idxs[i]].second--]=_;
		}
		for(int i = n/2;i<n;i++) {
//			assert(cnt[idxs[i]]);
			sum-=x[idxs[i]][s[idxs[i]].first];
			cnt[idxs[i]]--;
			res[idxs[i]][s[idxs[i]].first++]=_;
		}
	}
	allocate_tickets(res);
#undef int
	return sum;
}
# Verdict Execution time Memory 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 0 ms 348 KB Output is correct
6 Correct 1 ms 860 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Incorrect 0 ms 348 KB Contestant returned 4550041251 while correct return value is 4564307189.
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory 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 1 ms 348 KB Output is correct
5 Correct 10 ms 2524 KB Output is correct
6 Correct 299 ms 52512 KB Output is correct
7 Correct 282 ms 52820 KB Output is correct
8 Correct 2 ms 600 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 348 KB Output is correct
12 Correct 3 ms 860 KB Output is correct
13 Correct 10 ms 2060 KB Output is correct
14 Correct 18 ms 2112 KB Output is correct
15 Correct 303 ms 53328 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 20 ms 2572 KB Output is correct
6 Correct 4 ms 604 KB Output is correct
7 Correct 3 ms 860 KB Output is correct
8 Correct 403 ms 54440 KB Output is correct
9 Correct 415 ms 50724 KB Output is correct
10 Correct 390 ms 50768 KB Output is correct
11 Correct 440 ms 54420 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Incorrect 2 ms 348 KB Contestant returned 39312626459 while correct return value is 39376297182.
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Incorrect 2 ms 348 KB Contestant returned 39312626459 while correct return value is 39376297182.
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory 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 0 ms 348 KB Output is correct
6 Correct 1 ms 860 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Incorrect 0 ms 348 KB Contestant returned 4550041251 while correct return value is 4564307189.
10 Halted 0 ms 0 KB -