## Submission #352905

# Submission time Handle Problem Language Result Execution time Memory
352905 2021-01-21T05:00:52 Z Kerim Carnival Tickets (IOI20_tickets) C++17
100 / 100
925 ms 54356 KB
```#include "tickets.h"
#include "bits/stdc++.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;}
const int N=1502;
int l[N],r[N];
bool cmp(int x,int y){return (l[x]>l[y]);}
long long find_maximum(int k,vector<vector<int> > arr) {
priority_queue<pair<ll,int> >q;ll res=0;
int n=arr.size(),m=arr[0].size();vector<int>ind(n);
for(int i=0;i<n;i++){ind[i]=i;
for(int j=0;j<k;j++)res-=arr[i][j];
q.push(mp(arr[i][l[i]=k-1]+arr[i][r[i]=m-1],i));
}
for(int i=0;i<n*k/2;i++){
int ind=q.top().ss;res+=q.top().ff;q.pop();--l[ind];--r[ind];
if(l[ind]>=0)q.push(mp(arr[ind][l[ind]]+arr[ind][r[ind]],ind));
}
while(k--){sort(all(ind),cmp);
}
return res;
}```

#### Subtask #1 11.0 / 11.0

# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 3 ms 748 KB Output is correct

#### Subtask #2 16.0 / 16.0

# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 3 ms 492 KB Output is correct
5 Correct 28 ms 2412 KB Output is correct
6 Correct 633 ms 51564 KB Output is correct

#### Subtask #3 14.0 / 14.0

# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 2 ms 492 KB Output is correct
5 Correct 25 ms 2412 KB Output is correct
6 Correct 619 ms 52460 KB Output is correct
7 Correct 674 ms 52772 KB Output is correct
8 Correct 4 ms 620 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 7 ms 876 KB Output is correct
13 Correct 22 ms 2156 KB Output is correct
14 Correct 22 ms 2156 KB Output is correct
15 Correct 674 ms 53488 KB Output is correct

#### Subtask #4 14.0 / 14.0

# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 3 ms 492 KB Output is correct
5 Correct 33 ms 2540 KB Output is correct
6 Correct 8 ms 620 KB Output is correct
7 Correct 7 ms 876 KB Output is correct
8 Correct 887 ms 54356 KB Output is correct
9 Correct 843 ms 50668 KB Output is correct
10 Correct 812 ms 50668 KB Output is correct
11 Correct 925 ms 54304 KB Output is correct

#### Subtask #5 12.0 / 12.0

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

#### Subtask #6 23.0 / 23.0

# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 3 ms 492 KB Output is correct
3 Correct 2 ms 492 KB Output is correct
4 Correct 3 ms 492 KB Output is correct
5 Correct 4 ms 492 KB Output is correct
6 Correct 3 ms 620 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 3 ms 492 KB Output is correct
10 Correct 3 ms 492 KB Output is correct
11 Correct 3 ms 492 KB Output is correct
12 Correct 3 ms 492 KB Output is correct
13 Correct 26 ms 2412 KB Output is correct
14 Correct 29 ms 2412 KB Output is correct
15 Correct 30 ms 2412 KB Output is correct
16 Correct 34 ms 2540 KB Output is correct
17 Correct 1 ms 364 KB Output is correct
18 Correct 4 ms 492 KB Output is correct
19 Correct 2 ms 492 KB Output is correct
20 Correct 30 ms 2412 KB Output is correct
21 Correct 37 ms 2412 KB Output is correct
22 Correct 31 ms 2412 KB Output is correct
23 Correct 32 ms 2412 KB Output is correct

#### Subtask #7 10.0 / 10.0

# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 3 ms 748 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 3 ms 492 KB Output is correct
11 Correct 28 ms 2412 KB Output is correct
12 Correct 633 ms 51564 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
16 Correct 2 ms 492 KB Output is correct
17 Correct 25 ms 2412 KB Output is correct
18 Correct 619 ms 52460 KB Output is correct
19 Correct 674 ms 52772 KB Output is correct
20 Correct 4 ms 620 KB Output is correct
21 Correct 1 ms 364 KB Output is correct
22 Correct 1 ms 364 KB Output is correct
23 Correct 1 ms 364 KB Output is correct
24 Correct 7 ms 876 KB Output is correct
25 Correct 22 ms 2156 KB Output is correct
26 Correct 22 ms 2156 KB Output is correct
27 Correct 674 ms 53488 KB Output is correct
28 Correct 1 ms 364 KB Output is correct
29 Correct 1 ms 364 KB Output is correct
30 Correct 1 ms 364 KB Output is correct
31 Correct 3 ms 492 KB Output is correct
32 Correct 33 ms 2540 KB Output is correct
33 Correct 8 ms 620 KB Output is correct
34 Correct 7 ms 876 KB Output is correct
35 Correct 887 ms 54356 KB Output is correct
36 Correct 843 ms 50668 KB Output is correct
37 Correct 812 ms 50668 KB Output is correct
38 Correct 925 ms 54304 KB Output is correct
39 Correct 1 ms 364 KB Output is correct
40 Correct 3 ms 492 KB Output is correct
41 Correct 2 ms 492 KB Output is correct
42 Correct 3 ms 492 KB Output is correct
43 Correct 4 ms 492 KB Output is correct
44 Correct 3 ms 620 KB Output is correct
45 Correct 1 ms 364 KB Output is correct
46 Correct 1 ms 364 KB Output is correct
47 Correct 3 ms 492 KB Output is correct
48 Correct 3 ms 492 KB Output is correct
49 Correct 3 ms 492 KB Output is correct
50 Correct 3 ms 492 KB Output is correct
51 Correct 26 ms 2412 KB Output is correct
52 Correct 29 ms 2412 KB Output is correct
53 Correct 30 ms 2412 KB Output is correct
54 Correct 34 ms 2540 KB Output is correct
55 Correct 1 ms 364 KB Output is correct
56 Correct 4 ms 492 KB Output is correct
57 Correct 2 ms 492 KB Output is correct
58 Correct 30 ms 2412 KB Output is correct
59 Correct 37 ms 2412 KB Output is correct
60 Correct 31 ms 2412 KB Output is correct
61 Correct 32 ms 2412 KB Output is correct
62 Correct 72 ms 6252 KB Output is correct
63 Correct 98 ms 6124 KB Output is correct
64 Correct 94 ms 6252 KB Output is correct
65 Correct 376 ms 23660 KB Output is correct
66 Correct 377 ms 24172 KB Output is correct
67 Correct 7 ms 876 KB Output is correct
68 Correct 6 ms 620 KB Output is correct
69 Correct 642 ms 51432 KB Output is correct
70 Correct 787 ms 52752 KB Output is correct
71 Correct 895 ms 54252 KB Output is correct
72 Correct 750 ms 52320 KB Output is correct
73 Correct 859 ms 52288 KB Output is correct
74 Correct 650 ms 50796 KB Output is correct
75 Correct 742 ms 50796 KB Output is correct