Submission #1050402

# Submission time Handle Problem Language Result Execution time Memory
1050402 2024-08-09T09:10:41 Z mychecksedad Carnival Tickets (IOI20_tickets) C++17
27 / 100
466 ms 92064 KB
#include "tickets.h"
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define vi vector<int>
#define all(x) x.begin(),x.end()

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

	vector<array<int, 3>> a;	
	for(int i = 0; i < n; ++i) for(int j = 0; j < m; ++j) a.pb({x[i][j], i, j});
	sort(all(a));

	vector<deque<pair<int,int>>> C(n);

	// ll val = 0;
	for(int i = 0; i < n*m; ++i){
		C[a[i][1]].pb({a[i][0], a[i][2]});
	}
	for(int i = 0; i < n; ++i){
		// sort(all(C[i][0]), greater<pair<int,int>>());
		// sort(all(C[i]));
	}

	// cout << "f" << endl;
	ll val = 0;
	for(int i = 0; i < k; ++i){
		set<pair<ll, int>> S;
		for(int i = 0; i < n; ++i){
			ll dif = C[i].back().first + C[i].front().first;
			S.insert({dif, i});
		}
		int cur =0 ;
		auto it = S.begin();
		vector<ll> tot;
		while(it != S.end()){
			// cout << (*it).first << ' ' << (*it).second << "| ";
			int v = (*it).second;
			if(cur < n/2){
				tot.pb(C[v].front().first);
				answer[v][C[v].front().second] = i;
				C[v].pop_front();
			}else{
				tot.pb(C[v].back().first);
				answer[v][C[v].back().second] = i;
				C[v].pop_back();
			}
			++cur;
			it = next(it);
		}
		// cout << '\n';
		sort(all(tot));
		for(int j = 0; j < n/2; ++j){
			val += tot[j + n/2] - tot[j];
		}
		// for(int x: tot) cout << x << ' ';
		// cout << '\n';
		// cout << "f" << endl;
	}

	

	// for (int i = 0; i < n; i++) {
	// 	std::vector<int> row(m);
	// 	for (int j = 0; j < m; j++) {
	// 		if (j < k) {
	// 			row[j] = j;
	// 		} else {
	// 			row[j] = -1;
	// 		}
	// 	}
	// 	answer.push_back(row);
	// }
	allocate_tickets(answer);
	return val;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 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 604 KB Output is correct
6 Correct 2 ms 1628 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 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 680 KB Output is correct
5 Correct 18 ms 4000 KB Output is correct
6 Correct 466 ms 92064 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Contestant returned 5 while correct return value is 6.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Contestant returned 11 while correct return value is 13.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Contestant returned 11 while correct return value is 13.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Contestant returned 11 while correct return value is 13.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 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 604 KB Output is correct
6 Correct 2 ms 1628 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 680 KB Output is correct
11 Correct 18 ms 4000 KB Output is correct
12 Correct 466 ms 92064 KB Output is correct
13 Incorrect 0 ms 348 KB Contestant returned 5 while correct return value is 6.
14 Halted 0 ms 0 KB -