Submission #1106492

# Submission time Handle Problem Language Result Execution time Memory
1106492 2024-10-30T13:12:42 Z snpmrnhlol Carnival Tickets (IOI20_tickets) C++17
0 / 100
1 ms 336 KB
#include "tickets.h"
#include <bits/stdc++.h>
using namespace std;
const int N = 15e2;
vector<pair<int,int>> nr;
vector <int> bad;
int r[N];
int l[N];
long long find_maximum(int k, std::vector<std::vector<int>> x) {
	int n = x.size();
	int m = x[0].size();
	std::vector<std::vector<int>> answer;
    answer.resize(n);
	for(int i = 0;i < n;i++){
        answer[i].resize(m);
        for(int j = 0;j < k;j++){
            nr.push_back({- x[i][j] - x[i][m - k + j], i});
        }
        for(int j = 0;j < m;j++){
            answer[i][j] = -1;
        }
        l[i] = k;
	}
    sort(nr.begin(),nr.end());
    for(int i = 0;i < n*k/2;i++){
        r[nr[i].second]++;
        l[nr[i].second]--;
    }
    for(int i = 0;i < k;i++){
        int cnt1 = 0,cnt2 = 0;
        for(int j = 0;j < n;j++){
            if(cnt1 < cnt2){
                ///priority:cnt1
                if(r[j] != 0){
                    ///take right
                    answer[j][m - r[j]] = i;
                    cnt1++;
                    r[j]--;
                }else{
                    ///take left
                    answer[j][l[j] - 1] = i;
                    cnt2++;
                    l[j]--;
                }
            }else{
                if(l[j] != 0){
                    ///take left
                    answer[j][l[j] - 1] = i;
                    cnt2++;
                    l[j]--;
                }else{
                    ///take right
                    answer[j][m - r[j]] = i;
                    cnt1++;
                    r[j]--;
                }
            }
        }
    }
	allocate_tickets(answer);
	return 1;
}
/**
1, [[5, 9], [1, 4], [3, 6], [2, 7]]

4 2 1
5 9
1 4
3 6
2 7
**/
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 336 KB Contestant returned 298620960 but the tickets gives a total value of 1
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 336 KB Contestant returned 860858182 but the tickets gives a total value of 1
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 336 KB Contestant returned 4 but the tickets gives a total value of 1
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 336 KB Contestant returned 13 but the tickets gives a total value of 1
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 336 KB Contestant returned 13 but the tickets gives a total value of 1
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 336 KB Contestant returned 13 but the tickets gives a total value of 1
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 336 KB Contestant returned 298620960 but the tickets gives a total value of 1
2 Halted 0 ms 0 KB -