# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
304626 | 2020-09-21T15:37:38 Z | lolicon | Carnival Tickets (IOI20_tickets) | C++14 | 753 ms | 51704 KB |
#include "tickets.h" #include <bits/stdc++.h> using namespace std; #define all(x) begin(x), end(x) long long find_maximum(int k, vector<vector<int>> x) { int n = x.size(); int m = x[0].size(); vector<vector<int>> ans; for (int i = 0; i < n; i++) { vector<int> row(m, -1); ans.push_back(row); } int Cnt = 0; vector<int> cnt(n); vector<pair<int, int>> v; for(int i = 0; i < n; i++) { int l = x[i][0]; int r = x[i][m - 1]; v.emplace_back(l, i); v.emplace_back(r, i); v.emplace_back((l + r) / 2, i); } int p; sort(all(v)); for(int i = 0; i < 3 * n; i++) { cnt[v[i].second]++; if(cnt[v[i].second] == 2) { Cnt++; } if(Cnt == n / 2) { p = i; break; } } for(int i = 0; i < 3 * n; i++) { if(cnt[v[i].second] >= 2) ans[v[i].second][0] = 0; else ans[v[i].second][m - 1] = 0; } // cal long long ret = 0; vector<vector<int>> T(k); for(int i = 0; i < n; i++) { for(int j = 0; j < m; j++) { if(ans[i][j] != -1) { T[ans[i][j]].push_back(x[i][j]); } } } for(int i = 0; i < k; i++) { sort(begin(T[i]), end(T[i])); int p = T[i][n / 2]; for(int j = 0; j < n; j++) { ret = ret + (long long)abs(p - T[i][j]); } } allocate_tickets(ans); /*for(int i = 0; i < n; i++) { for(int j = 0; j < m; j++) { cout << ans[i][j] << " \n"[j == m - 1]; } }*/ return ret; }
Compilation message
# | 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 | 1 ms | 384 KB | Output is correct |
5 | Correct | 1 ms | 384 KB | Output is correct |
6 | Correct | 2 ms | 896 KB | Output is correct |
# | 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 | 31 ms | 2432 KB | Output is correct |
6 | Correct | 753 ms | 51704 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 1 ms | 384 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 1 ms | 384 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 1 ms | 384 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 1 ms | 384 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |
# | 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 | 1 ms | 384 KB | Output is correct |
5 | Correct | 1 ms | 384 KB | Output is correct |
6 | Correct | 2 ms | 896 KB | Output is correct |
7 | Correct | 0 ms | 256 KB | Output is correct |
8 | Correct | 0 ms | 256 KB | Output is correct |
9 | Correct | 1 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 | 753 ms | 51704 KB | Output is correct |
13 | Runtime error | 1 ms | 384 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
14 | Halted | 0 ms | 0 KB | - |