## Submission #433429

# Submission time Handle Problem Language Result Execution time Memory
433429 2021-06-19T18:54:18 Z Kerim Carnival Tickets (IOI20_tickets) C++17
100 / 100
893 ms 66484 KB
```#include <bits/stdc++.h>
#include "tickets.h"
#define MAXN 100009
#define INF 1000000007
#define mp(x,y) make_pair(x,y)
#define all(v) v.begin(),v.end()
#define pb(x) push_back(x)
#define wr cout<<"----------------"<<endl;
#define ppb() pop_back()
#define tr(ii,c) for(__typeof((c).begin()) ii=(c).begin();ii!=(c).end();ii++)
#define ff first
#define ss second
#define my_little_dodge 46
#define debug(x)  cerr<< #x <<" = "<< x<<endl;
using namespace std;

typedef long long ll;
typedef pair<int,int> PII;
template<class T>bool umin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T>bool umax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
using namespace std;
const int N=1502;
int l[N],r[N],ind[N],a[N][N];
bool cmp(int x,int y){
return (l[x]>l[y]);
}
long long find_maximum(int k, vector<vector<int>> arr) {
int n = arr.size();
int m = arr[0].size();
for(int i=0;i<n;i++)for(int j=0;j<m;j++)a[i+1][j+1]=arr[i][j];
vector<vector<int>> ans;
for (int i = 0; i < n; i++) {
vector<int> row(m,-1);
ans.push_back(row);
}
priority_queue<PII,vector<PII>,greater<PII> >q;
ll S=0;
for(int i=1;i<=n;i++){
r[i]=m-k+1;
l[i]=1;
q.push(mp(a[i][r[i]]+a[i][l[i]],i));
for(int j=m-k+1;j<=m;j++)
S+=a[i][j];
}
for(int rd=1;rd<=(n*k)/2;rd++){
PII nd=q.top();q.pop();
S-=nd.ff;
int i=nd.ss;
l[i]++;r[i]++;
if(r[i]<=m)
q.push(mp(a[i][r[i]]+a[i][l[i]],i));
}
for(int i=1;i<=n;i++)ind[i]=i;
for(int i=1;i<=n;i++)l[i]--,r[i]--;
while(k--){
sort(ind+1,ind+n+1,cmp);
for(int i=1;i<=n/2;i++)
ans[ind[i]-1][--l[ind[i]]]=k;
for(int i=n/2+1;i<=n;i++)
ans[ind[i]-1][r[ind[i]]++]=k;
}
allocate_tickets(ans);
return S;
}

```

#### Subtask #1 11.0 / 11.0

# Verdict Execution time Memory Grader output
1 Correct 1 ms 300 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 588 KB Output is correct
5 Correct 1 ms 1612 KB Output is correct
6 Correct 5 ms 6732 KB Output is correct

#### Subtask #2 16.0 / 16.0

# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 300 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 3 ms 844 KB Output is correct
5 Correct 31 ms 4820 KB Output is correct
6 Correct 678 ms 61656 KB Output is correct

#### Subtask #3 14.0 / 14.0

# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 2 ms 828 KB Output is correct
5 Correct 26 ms 4064 KB Output is correct
6 Correct 651 ms 62604 KB Output is correct
7 Correct 687 ms 62884 KB Output is correct
8 Correct 4 ms 972 KB Output is correct
9 Correct 1 ms 300 KB Output is correct
10 Correct 1 ms 308 KB Output is correct
11 Correct 1 ms 304 KB Output is correct
12 Correct 7 ms 1552 KB Output is correct
13 Correct 23 ms 4420 KB Output is correct
14 Correct 22 ms 3020 KB Output is correct
15 Correct 705 ms 63724 KB Output is correct

#### Subtask #4 14.0 / 14.0

# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 308 KB Output is correct
4 Correct 3 ms 844 KB Output is correct
5 Correct 34 ms 4840 KB Output is correct
6 Correct 6 ms 844 KB Output is correct
7 Correct 10 ms 7116 KB Output is correct
8 Correct 887 ms 65708 KB Output is correct
9 Correct 893 ms 60744 KB Output is correct
10 Correct 814 ms 60348 KB Output is correct
11 Correct 892 ms 66448 KB Output is correct

#### Subtask #5 12.0 / 12.0

# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 3 ms 844 KB Output is correct
3 Correct 3 ms 844 KB Output is correct
4 Correct 3 ms 844 KB Output is correct
5 Correct 3 ms 844 KB Output is correct
6 Correct 3 ms 844 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 560 KB Output is correct
9 Correct 3 ms 716 KB Output is correct
10 Correct 3 ms 832 KB Output is correct
11 Correct 3 ms 844 KB Output is correct
12 Correct 4 ms 844 KB Output is correct

#### Subtask #6 23.0 / 23.0

# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 3 ms 844 KB Output is correct
3 Correct 3 ms 844 KB Output is correct
4 Correct 3 ms 844 KB Output is correct
5 Correct 3 ms 844 KB Output is correct
6 Correct 3 ms 844 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 560 KB Output is correct
9 Correct 3 ms 716 KB Output is correct
10 Correct 3 ms 832 KB Output is correct
11 Correct 3 ms 844 KB Output is correct
12 Correct 4 ms 844 KB Output is correct
13 Correct 29 ms 4740 KB Output is correct
14 Correct 28 ms 4816 KB Output is correct
15 Correct 30 ms 4804 KB Output is correct
16 Correct 33 ms 4868 KB Output is correct
17 Correct 1 ms 312 KB Output is correct
18 Correct 3 ms 1740 KB Output is correct
19 Correct 2 ms 1612 KB Output is correct
20 Correct 28 ms 4164 KB Output is correct
21 Correct 30 ms 4676 KB Output is correct
22 Correct 35 ms 4220 KB Output is correct
23 Correct 32 ms 4676 KB Output is correct

#### Subtask #7 10.0 / 10.0

# Verdict Execution time Memory Grader output
1 Correct 1 ms 300 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 588 KB Output is correct
5 Correct 1 ms 1612 KB Output is correct
6 Correct 5 ms 6732 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 332 KB Output is correct
10 Correct 3 ms 844 KB Output is correct
11 Correct 31 ms 4820 KB Output is correct
12 Correct 678 ms 61656 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
16 Correct 2 ms 828 KB Output is correct
17 Correct 26 ms 4064 KB Output is correct
18 Correct 651 ms 62604 KB Output is correct
19 Correct 687 ms 62884 KB Output is correct
20 Correct 4 ms 972 KB Output is correct
21 Correct 1 ms 300 KB Output is correct
22 Correct 1 ms 308 KB Output is correct
23 Correct 1 ms 304 KB Output is correct
24 Correct 7 ms 1552 KB Output is correct
25 Correct 23 ms 4420 KB Output is correct
26 Correct 22 ms 3020 KB Output is correct
27 Correct 705 ms 63724 KB Output is correct
28 Correct 1 ms 332 KB Output is correct
29 Correct 1 ms 332 KB Output is correct
30 Correct 1 ms 308 KB Output is correct
31 Correct 3 ms 844 KB Output is correct
32 Correct 34 ms 4840 KB Output is correct
33 Correct 6 ms 844 KB Output is correct
34 Correct 10 ms 7116 KB Output is correct
35 Correct 887 ms 65708 KB Output is correct
36 Correct 893 ms 60744 KB Output is correct
37 Correct 814 ms 60348 KB Output is correct
38 Correct 892 ms 66448 KB Output is correct
39 Correct 1 ms 332 KB Output is correct
40 Correct 3 ms 844 KB Output is correct
41 Correct 3 ms 844 KB Output is correct
42 Correct 3 ms 844 KB Output is correct
43 Correct 3 ms 844 KB Output is correct
44 Correct 3 ms 844 KB Output is correct
45 Correct 1 ms 332 KB Output is correct
46 Correct 1 ms 560 KB Output is correct
47 Correct 3 ms 716 KB Output is correct
48 Correct 3 ms 832 KB Output is correct
49 Correct 3 ms 844 KB Output is correct
50 Correct 4 ms 844 KB Output is correct
51 Correct 29 ms 4740 KB Output is correct
52 Correct 28 ms 4816 KB Output is correct
53 Correct 30 ms 4804 KB Output is correct
54 Correct 33 ms 4868 KB Output is correct
55 Correct 1 ms 312 KB Output is correct
56 Correct 3 ms 1740 KB Output is correct
57 Correct 2 ms 1612 KB Output is correct
58 Correct 28 ms 4164 KB Output is correct
59 Correct 30 ms 4676 KB Output is correct
60 Correct 35 ms 4220 KB Output is correct
61 Correct 32 ms 4676 KB Output is correct
62 Correct 73 ms 10176 KB Output is correct
63 Correct 96 ms 10180 KB Output is correct
64 Correct 93 ms 10408 KB Output is correct
65 Correct 345 ms 30904 KB Output is correct
66 Correct 375 ms 31456 KB Output is correct
67 Correct 10 ms 7116 KB Output is correct
68 Correct 6 ms 876 KB Output is correct
69 Correct 680 ms 62824 KB Output is correct
70 Correct 768 ms 64604 KB Output is correct
71 Correct 870 ms 66484 KB Output is correct
72 Correct 774 ms 62720 KB Output is correct
73 Correct 859 ms 62152 KB Output is correct
74 Correct 673 ms 61152 KB Output is correct
75 Correct 737 ms 60620 KB Output is correct