# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
588758 | 2022-07-04T03:11:06 Z | LIF | Carnival Tickets (IOI20_tickets) | C++14 | 453 ms | 73308 KB |
#include "tickets.h" #include <vector> #include<bits/stdc++.h> using namespace std; bool cmp(long long int x,long long int y) { return x<y; } struct node { int least; int maxn; long long int val; int id; }nod[10005]; bool cmp2(node x,node y) { return x.val < y.val; } long long find_maximum(int k, std::vector<std::vector<int> > x) { int mm = x[0].size(); //find the m; int n = x.size(); vector<vector <int> > s; long long int a[20005]; long long int sum =0; if(mm==1) { for(int i=0;i<n;i++) { vector <int> q; q.push_back(0); s.push_back(q); } for(int i=0;i<n;i++) { a[i] = x[i][0]; } sort(a,a+n); long long int ans = a[n/2-1]+a[n/2]; ans /=2; for(int i=0;i<n;i++) { sum += abs(ans - a[i]); } allocate_tickets(s); return sum; } if(k==1) { for(int i=0;i<n;i++) { long long int xx = x[i][0] + x[i][mm-1]; nod[i].val = xx; nod[i].id = i; nod[i].least = x[i][0]; nod[i].maxn = x[i][mm-1]; } sort(nod,nod+n,cmp2); //from small to big for(int i=0;i<n;i++) { vector<int> q; for(int j=0;j<mm;j++) { q.push_back(-1); } s.push_back(q); } for(int i=0;i<n/2;i++) //it is the range of small { int id = nod[i].id; s[id][0] = 0; } for(int i=n/2;i<n;i++) { int id = nod[i].id; s[id][mm-1] = 0; } allocate_tickets(s); for(int i=0;i<n;i++) { if(i<n/2) { a[i] = nod[i].least; } else { a[i] = nod[i].maxn; } } sort(a,a+n); long long int ans = a[n/2] + a[n/2-1]; ans /=2; for(int i=0;i<n;i++) { sum += abs(a[i] - ans); } return sum; } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 468 KB | Output is correct |
2 | Correct | 1 ms | 468 KB | Output is correct |
3 | Correct | 1 ms | 468 KB | Output is correct |
4 | Correct | 1 ms | 468 KB | Output is correct |
5 | Correct | 1 ms | 468 KB | Output is correct |
6 | Correct | 2 ms | 852 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 340 KB | Output is correct |
2 | Correct | 1 ms | 436 KB | Output is correct |
3 | Correct | 1 ms | 468 KB | Output is correct |
4 | Correct | 2 ms | 596 KB | Output is correct |
5 | Correct | 20 ms | 3404 KB | Output is correct |
6 | Correct | 453 ms | 73308 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 2 ms | 852 KB | Execution killed with signal 6 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 2 ms | 852 KB | Execution killed with signal 6 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 2 ms | 852 KB | Execution killed with signal 6 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 2 ms | 852 KB | Execution killed with signal 6 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 468 KB | Output is correct |
2 | Correct | 1 ms | 468 KB | Output is correct |
3 | Correct | 1 ms | 468 KB | Output is correct |
4 | Correct | 1 ms | 468 KB | Output is correct |
5 | Correct | 1 ms | 468 KB | Output is correct |
6 | Correct | 2 ms | 852 KB | Output is correct |
7 | Correct | 1 ms | 340 KB | Output is correct |
8 | Correct | 1 ms | 436 KB | Output is correct |
9 | Correct | 1 ms | 468 KB | Output is correct |
10 | Correct | 2 ms | 596 KB | Output is correct |
11 | Correct | 20 ms | 3404 KB | Output is correct |
12 | Correct | 453 ms | 73308 KB | Output is correct |
13 | Runtime error | 2 ms | 852 KB | Execution killed with signal 6 |
14 | Halted | 0 ms | 0 KB | - |