답안 #399996

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
399996 2021-05-07T02:59:36 Z faresbasbs 카니발 티켓 (IOI20_tickets) C++14
100 / 100
931 ms 73172 KB
#include <bits/stdc++.h>
#include "tickets.h"
using namespace std;
int n,m,l[1501],r[1501];

long long find_maximum(int k, vector<vector<int>> x){
	n = x.size() , m = x[0].size();
	vector<vector<int>> ans(n,vector<int>(m,-1));
	vector<pair<int,int>> vals;
	long long ret = 0;
	priority_queue<pair<int,int>> pq;
	for(int i = 0 ; i < n ; i += 1){
		vals.push_back({0,i});
		l[i] = k-1 , r[i] = m-1;
		pq.push({x[i][k-1]+x[i][m-1],i});
	}
	for(int i = 0 ; i < (n*k)/2 ; i += 1){
		pair<int,int> nxt = pq.top();
		pq.pop();
		vals[nxt.second].first += 1;
		l[nxt.second] -= 1 , r[nxt.second] -= 1;
		if(l[nxt.second] != -1){
			pq.push({x[nxt.second][l[nxt.second]]+x[nxt.second][r[nxt.second]],nxt.second});
		}
	}
	for(int i = 0 ; i < n ; i += 1){
		l[i] = 0 , r[i] = m-1;
	}
	for(int i = 0 ; i < k ; i += 1){
		sort(vals.begin(),vals.end());
		for(int j = 0 ; j < n/2 ; j += 1){
			int p = vals[j].second;
			ret -= x[p][l[p]];
			ans[p][l[p]] = i;
			l[p] += 1;
		}
		for(int j = n/2 ; j < n ; j += 1){
			int p = vals[j].second;
			ret += x[p][r[p]];
			ans[p][r[p]] = i;
			r[p] -= 1;
			vals[j].first -= 1;
		}
	}
	allocate_tickets(ans);
	return ret;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 296 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 2 ms 716 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 300 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 3 ms 460 KB Output is correct
5 Correct 29 ms 3168 KB Output is correct
6 Correct 677 ms 73172 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 304 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 3 ms 460 KB Output is correct
5 Correct 27 ms 2556 KB Output is correct
6 Correct 661 ms 52664 KB Output is correct
7 Correct 694 ms 53032 KB Output is correct
8 Correct 4 ms 460 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 296 KB Output is correct
11 Correct 1 ms 304 KB Output is correct
12 Correct 8 ms 824 KB Output is correct
13 Correct 24 ms 2116 KB Output is correct
14 Correct 29 ms 2096 KB Output is correct
15 Correct 760 ms 53604 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 5 ms 432 KB Output is correct
5 Correct 39 ms 2884 KB Output is correct
6 Correct 6 ms 716 KB Output is correct
7 Correct 8 ms 972 KB Output is correct
8 Correct 931 ms 54356 KB Output is correct
9 Correct 869 ms 50692 KB Output is correct
10 Correct 892 ms 50652 KB Output is correct
11 Correct 927 ms 54412 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 3 ms 460 KB Output is correct
3 Correct 3 ms 460 KB Output is correct
4 Correct 3 ms 460 KB Output is correct
5 Correct 3 ms 460 KB Output is correct
6 Correct 4 ms 444 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 3 ms 460 KB Output is correct
10 Correct 3 ms 460 KB Output is correct
11 Correct 3 ms 460 KB Output is correct
12 Correct 3 ms 460 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 3 ms 460 KB Output is correct
3 Correct 3 ms 460 KB Output is correct
4 Correct 3 ms 460 KB Output is correct
5 Correct 3 ms 460 KB Output is correct
6 Correct 4 ms 444 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 3 ms 460 KB Output is correct
10 Correct 3 ms 460 KB Output is correct
11 Correct 3 ms 460 KB Output is correct
12 Correct 3 ms 460 KB Output is correct
13 Correct 31 ms 3172 KB Output is correct
14 Correct 29 ms 3160 KB Output is correct
15 Correct 31 ms 3268 KB Output is correct
16 Correct 35 ms 3292 KB Output is correct
17 Correct 2 ms 332 KB Output is correct
18 Correct 3 ms 460 KB Output is correct
19 Correct 3 ms 440 KB Output is correct
20 Correct 29 ms 2628 KB Output is correct
21 Correct 31 ms 3140 KB Output is correct
22 Correct 32 ms 2596 KB Output is correct
23 Correct 34 ms 3224 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 296 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 2 ms 716 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 300 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 3 ms 460 KB Output is correct
11 Correct 29 ms 3168 KB Output is correct
12 Correct 677 ms 73172 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 1 ms 304 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 3 ms 460 KB Output is correct
17 Correct 27 ms 2556 KB Output is correct
18 Correct 661 ms 52664 KB Output is correct
19 Correct 694 ms 53032 KB Output is correct
20 Correct 4 ms 460 KB Output is correct
21 Correct 1 ms 204 KB Output is correct
22 Correct 1 ms 296 KB Output is correct
23 Correct 1 ms 304 KB Output is correct
24 Correct 8 ms 824 KB Output is correct
25 Correct 24 ms 2116 KB Output is correct
26 Correct 29 ms 2096 KB Output is correct
27 Correct 760 ms 53604 KB Output is correct
28 Correct 1 ms 204 KB Output is correct
29 Correct 1 ms 204 KB Output is correct
30 Correct 1 ms 204 KB Output is correct
31 Correct 5 ms 432 KB Output is correct
32 Correct 39 ms 2884 KB Output is correct
33 Correct 6 ms 716 KB Output is correct
34 Correct 8 ms 972 KB Output is correct
35 Correct 931 ms 54356 KB Output is correct
36 Correct 869 ms 50692 KB Output is correct
37 Correct 892 ms 50652 KB Output is correct
38 Correct 927 ms 54412 KB Output is correct
39 Correct 1 ms 204 KB Output is correct
40 Correct 3 ms 460 KB Output is correct
41 Correct 3 ms 460 KB Output is correct
42 Correct 3 ms 460 KB Output is correct
43 Correct 3 ms 460 KB Output is correct
44 Correct 4 ms 444 KB Output is correct
45 Correct 1 ms 332 KB Output is correct
46 Correct 1 ms 332 KB Output is correct
47 Correct 3 ms 460 KB Output is correct
48 Correct 3 ms 460 KB Output is correct
49 Correct 3 ms 460 KB Output is correct
50 Correct 3 ms 460 KB Output is correct
51 Correct 31 ms 3172 KB Output is correct
52 Correct 29 ms 3160 KB Output is correct
53 Correct 31 ms 3268 KB Output is correct
54 Correct 35 ms 3292 KB Output is correct
55 Correct 2 ms 332 KB Output is correct
56 Correct 3 ms 460 KB Output is correct
57 Correct 3 ms 440 KB Output is correct
58 Correct 29 ms 2628 KB Output is correct
59 Correct 31 ms 3140 KB Output is correct
60 Correct 32 ms 2596 KB Output is correct
61 Correct 34 ms 3224 KB Output is correct
62 Correct 75 ms 8388 KB Output is correct
63 Correct 79 ms 8436 KB Output is correct
64 Correct 96 ms 8644 KB Output is correct
65 Correct 345 ms 33124 KB Output is correct
66 Correct 398 ms 33620 KB Output is correct
67 Correct 8 ms 972 KB Output is correct
68 Correct 7 ms 772 KB Output is correct
69 Correct 698 ms 73096 KB Output is correct
70 Correct 811 ms 66552 KB Output is correct
71 Correct 909 ms 57108 KB Output is correct
72 Correct 835 ms 52396 KB Output is correct
73 Correct 879 ms 66788 KB Output is correct
74 Correct 712 ms 59032 KB Output is correct
75 Correct 883 ms 52568 KB Output is correct