제출 #451969

#제출 시각아이디문제언어결과실행 시간메모리
451969rainboy카니발 티켓 (IOI20_tickets)C++17
27 / 100
640 ms73064 KiB
#include "tickets.h"

using namespace std;

typedef vector<int> vi;

const int N = 1500, M = 1500;

unsigned int X = 12345;

int rand_() {
	return (X *= 3) >> 1;
}

int aa_[N], ii[N];

void sort(int *ii, int l, int r) {
	while (l < r) {
		int i = l, j = l, k = r, i_ = ii[l + rand_() % (r - l)], tmp;

		while (j < k)
			if (aa_[ii[j]] == aa_[i_])
				j++;
			else if (aa_[ii[j]] < aa_[i_]) {
				tmp = ii[i], ii[i] = ii[j], ii[j] = tmp;
				i++, j++;
			} else {
				k--;
				tmp = ii[j], ii[j] = ii[k], ii[k] = tmp;
			}
		sort(ii, l, i);
		l = k;
	}
}

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

	for (i = 0; i < n; i++) {
		hh[i].resize(m);
		for (j = 0; j < m; j++)
			hh[i][j] = -1;
	}
	ans = 0;
	for (i = 0; i < n; i++) {
		ans -= aa[i][0];
		aa_[i] = aa[i][m - 1] + aa[i][0];
		hh[i][0] = 0;
		ii[i] = i;
	}
	sort(ii, 0, n);
	for (i = n / 2; i < n; i++) {
		int i_ = ii[i];

		hh[i_][0] = -1, hh[i_][m - 1] = 0;
		ans += aa_[i_];
	}
	allocate_tickets(hh);
	return ans;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...