## Submission #301844

# Submission time Handle Problem Language Result Execution time Memory
301844 2020-09-18T08:49:31 Z majk Carnival Tickets (IOI20_tickets) C++17
100 / 100
861 ms 62360 KB
```#include <vector>
#include <algorithm>
#include "tickets.h"
using namespace std;

#define x first
#define y second
typedef std::pair<int,int> pii; typedef long long ll;
template<typename T>class vector2:public vector<vector<T>>{public:vector2(){} vector2(size_t a,size_t b,T t=T()):vector<vector<T>>(a,vector<T>(b,t)){}};

ll find_maximum(int K, vector<vector<int>> A) {
int N = A.size(), M = A[0].size();

ll tot = 0;
vector<pii> S;
for (int i = 0; i < N; ++i) {
for (int j = 0; j < K; ++j) {
tot += A[i][j+M-K];
S.push_back({A[i][j] + A[i][j+M-K], i});
}
}
nth_element(S.begin(), S.begin() + N*K/2, S.end());
vector<int> CntLo(N, 0), CntHi(N);
for (int i = 0; i < N*K/2; ++i) {
tot -= S[i].x;
CntLo[S[i].y]++;
}
for (int i = 0; i < N; ++i) CntHi[i] = K - CntLo[i];
vector2<int> T(N, M, -1);
for (int i = 0; i < K; ++i) {
int lo = N/2, hi = N/2;
for (int j = 0; j < N; ++j) {
if (CntLo[j] == 0) hi--;
if (CntLo[j] == K-i) lo--;
}

for (int j = 0; j < N; ++j) {
if (CntLo[j] == 0) {
T[j][M-CntHi[j]] = i;
--CntHi[j];
} else if (CntLo[j] == K-i) {
--CntLo[j];
T[j][CntLo[j]] = i;
} else if (lo > 0) {
--CntLo[j];
--lo;
T[j][CntLo[j]] = i;
} else {
T[j][M-CntHi[j]] = i;
--CntHi[j];
--hi;
}
}
}
allocate_tickets(T);
}```

#### Subtask #1 11.0 / 11.0

# Verdict Execution time Memory Grader output
1 Correct 0 ms 256 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 1 ms 256 KB Output is correct
4 Correct 1 ms 256 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 2 ms 768 KB Output is correct

#### Subtask #2 16.0 / 16.0

# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 1 ms 256 KB Output is correct
3 Correct 0 ms 256 KB Output is correct
4 Correct 3 ms 512 KB Output is correct
5 Correct 31 ms 2432 KB Output is correct
6 Correct 761 ms 51448 KB Output is correct

#### Subtask #3 14.0 / 14.0

# Verdict Execution time Memory Grader output
1 Correct 0 ms 256 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 0 ms 256 KB Output is correct
4 Correct 2 ms 512 KB Output is correct
5 Correct 24 ms 2460 KB Output is correct
6 Correct 613 ms 53468 KB Output is correct
7 Correct 618 ms 56380 KB Output is correct
8 Correct 3 ms 640 KB Output is correct
9 Correct 0 ms 256 KB Output is correct
10 Correct 0 ms 384 KB Output is correct
11 Correct 1 ms 256 KB Output is correct
12 Correct 7 ms 896 KB Output is correct
13 Correct 26 ms 2300 KB Output is correct
14 Correct 29 ms 2204 KB Output is correct
15 Correct 635 ms 58684 KB Output is correct

#### Subtask #4 14.0 / 14.0

# Verdict Execution time Memory Grader output
1 Correct 0 ms 256 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 1 ms 256 KB Output is correct
4 Correct 3 ms 512 KB Output is correct
5 Correct 34 ms 2808 KB Output is correct
6 Correct 6 ms 768 KB Output is correct
7 Correct 7 ms 1024 KB Output is correct
8 Correct 845 ms 62360 KB Output is correct
9 Correct 782 ms 58280 KB Output is correct
10 Correct 776 ms 58264 KB Output is correct
11 Correct 830 ms 62340 KB Output is correct

#### Subtask #5 12.0 / 12.0

# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 4 ms 512 KB Output is correct
3 Correct 3 ms 512 KB Output is correct
4 Correct 4 ms 512 KB Output is correct
5 Correct 3 ms 512 KB Output is correct
6 Correct 3 ms 512 KB Output is correct
7 Correct 1 ms 256 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 3 ms 512 KB Output is correct
10 Correct 3 ms 512 KB Output is correct
11 Correct 2 ms 512 KB Output is correct
12 Correct 3 ms 512 KB Output is correct

#### Subtask #6 23.0 / 23.0

# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 4 ms 512 KB Output is correct
3 Correct 3 ms 512 KB Output is correct
4 Correct 4 ms 512 KB Output is correct
5 Correct 3 ms 512 KB Output is correct
6 Correct 3 ms 512 KB Output is correct
7 Correct 1 ms 256 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 3 ms 512 KB Output is correct
10 Correct 3 ms 512 KB Output is correct
11 Correct 2 ms 512 KB Output is correct
12 Correct 3 ms 512 KB Output is correct
13 Correct 38 ms 2432 KB Output is correct
14 Correct 31 ms 2432 KB Output is correct
15 Correct 34 ms 2580 KB Output is correct
16 Correct 36 ms 2808 KB Output is correct
17 Correct 1 ms 384 KB Output is correct
18 Correct 3 ms 512 KB Output is correct
19 Correct 2 ms 384 KB Output is correct
20 Correct 27 ms 2556 KB Output is correct
21 Correct 35 ms 2544 KB Output is correct
22 Correct 27 ms 2676 KB Output is correct
23 Correct 33 ms 2676 KB Output is correct

#### Subtask #7 10.0 / 10.0

# Verdict Execution time Memory Grader output
1 Correct 0 ms 256 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 1 ms 256 KB Output is correct
4 Correct 1 ms 256 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 2 ms 768 KB Output is correct
7 Correct 1 ms 256 KB Output is correct
8 Correct 1 ms 256 KB Output is correct
9 Correct 0 ms 256 KB Output is correct
10 Correct 3 ms 512 KB Output is correct
11 Correct 31 ms 2432 KB Output is correct
12 Correct 761 ms 51448 KB Output is correct
13 Correct 0 ms 256 KB Output is correct
14 Correct 0 ms 256 KB Output is correct
15 Correct 0 ms 256 KB Output is correct
16 Correct 2 ms 512 KB Output is correct
17 Correct 24 ms 2460 KB Output is correct
18 Correct 613 ms 53468 KB Output is correct
19 Correct 618 ms 56380 KB Output is correct
20 Correct 3 ms 640 KB Output is correct
21 Correct 0 ms 256 KB Output is correct
22 Correct 0 ms 384 KB Output is correct
23 Correct 1 ms 256 KB Output is correct
24 Correct 7 ms 896 KB Output is correct
25 Correct 26 ms 2300 KB Output is correct
26 Correct 29 ms 2204 KB Output is correct
27 Correct 635 ms 58684 KB Output is correct
28 Correct 0 ms 256 KB Output is correct
29 Correct 0 ms 256 KB Output is correct
30 Correct 1 ms 256 KB Output is correct
31 Correct 3 ms 512 KB Output is correct
32 Correct 34 ms 2808 KB Output is correct
33 Correct 6 ms 768 KB Output is correct
34 Correct 7 ms 1024 KB Output is correct
35 Correct 845 ms 62360 KB Output is correct
36 Correct 782 ms 58280 KB Output is correct
37 Correct 776 ms 58264 KB Output is correct
38 Correct 830 ms 62340 KB Output is correct
39 Correct 1 ms 384 KB Output is correct
40 Correct 4 ms 512 KB Output is correct
41 Correct 3 ms 512 KB Output is correct
42 Correct 4 ms 512 KB Output is correct
43 Correct 3 ms 512 KB Output is correct
44 Correct 3 ms 512 KB Output is correct
45 Correct 1 ms 256 KB Output is correct
46 Correct 1 ms 384 KB Output is correct
47 Correct 3 ms 512 KB Output is correct
48 Correct 3 ms 512 KB Output is correct
49 Correct 2 ms 512 KB Output is correct
50 Correct 3 ms 512 KB Output is correct
51 Correct 38 ms 2432 KB Output is correct
52 Correct 31 ms 2432 KB Output is correct
53 Correct 34 ms 2580 KB Output is correct
54 Correct 36 ms 2808 KB Output is correct
55 Correct 1 ms 384 KB Output is correct
56 Correct 3 ms 512 KB Output is correct
57 Correct 2 ms 384 KB Output is correct
58 Correct 27 ms 2556 KB Output is correct
59 Correct 35 ms 2544 KB Output is correct
60 Correct 27 ms 2676 KB Output is correct
61 Correct 33 ms 2676 KB Output is correct
62 Correct 112 ms 6008 KB Output is correct
63 Correct 86 ms 6136 KB Output is correct
64 Correct 103 ms 7272 KB Output is correct
65 Correct 398 ms 24040 KB Output is correct
66 Correct 363 ms 28040 KB Output is correct
67 Correct 7 ms 1024 KB Output is correct
68 Correct 6 ms 768 KB Output is correct
69 Correct 774 ms 51444 KB Output is correct
70 Correct 808 ms 53692 KB Output is correct
71 Correct 861 ms 62240 KB Output is correct
72 Correct 681 ms 59544 KB Output is correct
73 Correct 819 ms 59080 KB Output is correct
74 Correct 654 ms 52668 KB Output is correct
75 Correct 776 ms 52420 KB Output is correct