Submission #850680

# Submission time Handle Problem Language Result Execution time Memory
850680 2023-09-17T09:19:58 Z abcvuitunggio Carnival Tickets (IOI20_tickets) C++17
62 / 100
3000 ms 88256 KB
#include "tickets.h"
#include <vector>
#include <bits/stdc++.h>
using namespace std;
long long find_maximum(int k, vector <vector <int>> x) {
	int n=x.size(),m=x[0].size();
	int idx[n];
	long long res=0;
	vector <vector <int>> answer;
	vector <int> v[n];
	answer.resize(n);
	for (int i=0;i<n;i++){
        idx[i]=k;
        answer[i].resize(m,-1);
        for (int j=k-1;j>=0;j--){
            res-=x[i][j];
            v[i].push_back(x[i][m-j-1]+x[i][k-j-1]);
        }
    }
    for (int i=0;i<n*k/2;i++){
        pair <int, int> mx={0,-1};
        for (int j=0;j<n;j++)
            if (!v[j].empty())
                mx=max(mx,make_pair(v[j].back(),j));
        res+=mx.first;
        idx[mx.second]--;
        v[mx.second].pop_back();
    }
    vector <pair <int, int>> ve;
    for (int i=0;i<k;i++){
        ve.clear();
        for (int j=0;j<n;j++)
            ve.push_back({idx[j],j});
        sort(ve.begin(),ve.end());
        for (int j=0;j<n/2;j++){
            x[ve[j].second].pop_back();
            answer[ve[j].second][x[ve[j].second].size()]=i;
        }
        for (int j=n/2;j<n;j++){
            idx[ve[j].second]--;
            answer[ve[j].second][idx[ve[j].second]]=i;
        }
    }
	allocate_tickets(answer);
	return res;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 1 ms 600 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 5 ms 760 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 2 ms 344 KB Output is correct
5 Correct 16 ms 2396 KB Output is correct
6 Correct 387 ms 51624 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 2 ms 604 KB Output is correct
5 Correct 31 ms 2600 KB Output is correct
6 Correct 2211 ms 58408 KB Output is correct
7 Correct 2472 ms 58932 KB Output is correct
8 Correct 3 ms 604 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 7 ms 860 KB Output is correct
13 Correct 35 ms 2392 KB Output is correct
14 Correct 21 ms 2396 KB Output is correct
15 Execution timed out 3029 ms 70104 KB Time limit exceeded
16 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 2 ms 604 KB Output is correct
5 Correct 35 ms 3164 KB Output is correct
6 Correct 4 ms 856 KB Output is correct
7 Correct 17 ms 1112 KB Output is correct
8 Correct 2941 ms 88256 KB Output is correct
9 Correct 2963 ms 83928 KB Output is correct
10 Correct 2704 ms 82508 KB Output is correct
11 Execution timed out 3048 ms 82216 KB Time limit exceeded
12 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 2 ms 348 KB Output is correct
3 Correct 2 ms 348 KB Output is correct
4 Correct 2 ms 600 KB Output is correct
5 Correct 2 ms 600 KB Output is correct
6 Correct 2 ms 604 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 344 KB Output is correct
9 Correct 2 ms 604 KB Output is correct
10 Correct 2 ms 604 KB Output is correct
11 Correct 2 ms 604 KB Output is correct
12 Correct 2 ms 604 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 2 ms 348 KB Output is correct
3 Correct 2 ms 348 KB Output is correct
4 Correct 2 ms 600 KB Output is correct
5 Correct 2 ms 600 KB Output is correct
6 Correct 2 ms 604 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 344 KB Output is correct
9 Correct 2 ms 604 KB Output is correct
10 Correct 2 ms 604 KB Output is correct
11 Correct 2 ms 604 KB Output is correct
12 Correct 2 ms 604 KB Output is correct
13 Correct 17 ms 3192 KB Output is correct
14 Correct 17 ms 3336 KB Output is correct
15 Correct 28 ms 3716 KB Output is correct
16 Correct 35 ms 3928 KB Output is correct
17 Correct 1 ms 344 KB Output is correct
18 Correct 2 ms 600 KB Output is correct
19 Correct 2 ms 348 KB Output is correct
20 Correct 29 ms 2896 KB Output is correct
21 Correct 29 ms 3676 KB Output is correct
22 Correct 37 ms 3412 KB Output is correct
23 Correct 33 ms 3924 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 1 ms 600 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 5 ms 760 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 2 ms 344 KB Output is correct
11 Correct 16 ms 2396 KB Output is correct
12 Correct 387 ms 51624 KB Output is correct
13 Correct 0 ms 344 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 2 ms 604 KB Output is correct
17 Correct 31 ms 2600 KB Output is correct
18 Correct 2211 ms 58408 KB Output is correct
19 Correct 2472 ms 58932 KB Output is correct
20 Correct 3 ms 604 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 7 ms 860 KB Output is correct
25 Correct 35 ms 2392 KB Output is correct
26 Correct 21 ms 2396 KB Output is correct
27 Execution timed out 3029 ms 70104 KB Time limit exceeded
28 Halted 0 ms 0 KB -