# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
426834 | 2021-06-14T10:17:41 Z | zoooma13 | Carnival Tickets (IOI20_tickets) | C++14 | 2 ms | 716 KB |
#include "bits/stdc++.h" #include "tickets.h" using namespace std; long long find_maximum(int k, vector<vector<int>> x) { int n = x.size(); int m = x[0].size(); assert(m == k); vector <array <int ,3>> all; //{val ,color ,index} for(int i = 0; i < n; i++) for(int j = 0; j < m; j++) all.push_back({x[i][j] ,i ,j}); sort(all.begin() ,all.end()); int64_t tot = 0; vector<vector<int>> answer(n ,vector<int>(m ,-1)); set <int> mex[n]; for(int i = 0; i < k; i++) for(int c = 0; c < n; c++) mex[c].insert(i); vector <int> sizes(k); set <int> mexsizes; for(int i = 0; i < k; i++) mexsizes.insert(i); for(int i = 0; i < (int)all.size()/2; i++){ tot -= all[i][0]; int p = max(*mex[all[i][1]].begin() ,*mexsizes.begin()); sizes[p]++; if(sizes[p] == n/2) mexsizes.erase(p); mex[all[i][1]].erase(p); answer[all[i][1]][all[i][2]] = p; } for(int i = (int)all.size()/2; i < all.size(); i++){ tot += all[i][0]; int p = *mex[all[i][1]].begin(); mex[all[i][1]].erase(p); answer[all[i][1]][all[i][2]] = p; } allocate_tickets(answer); return tot; }
Compilation message
# | Verdict | Execution time | Memory | 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 | 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 |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 1 ms | 332 KB | Execution killed with signal 6 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 1 ms | 332 KB | Execution killed with signal 6 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 204 KB | There is no ticket of color 0 on day 0 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 204 KB | There is no ticket of color 0 on day 0 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 204 KB | There is no ticket of color 0 on day 0 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | 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 | 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 | Runtime error | 1 ms | 332 KB | Execution killed with signal 6 |
8 | Halted | 0 ms | 0 KB | - |