This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
#include "tickets.h"
using namespace std;
bool chk[1501][1501];
long long find_maximum(int k, vector<vector<int> > x){
vector<vector<int> > s(x.size());
for(int i = 0;i < s.size();i++) s[i].resize(x[0].size(), -1);
long long ret = 0;
priority_queue<pair<pair<long long, int>, pair<int, int> > > pq;
for(int i = 0;i < x.size();i++){
for(int j = 0;j < k;j++){
ret -= x[i][j];
chk[i][j] = true;
}
pq.push({{x[i].back() + x[i][k - 1], i}, {x[i].size() - 1, k - 1}});
}
for(int i = 0;i < k*x.size()/2;i++){
ret += pq.top().first.first;
int a = pq.top().second.first;
int b = pq.top().second.second;
int c = pq.top().first.second;
chk[c][b] = false; chk[c][a] = true;
pq.pop();
pq.push({{x[c][a-1] + x[c][b-1], c}, {a-1, b-1}});
}
for(int i = 0;i < x.size();i++){
int cnt = k - 1, cntp = -1;
if(i%2 == 0) cnt = 0, cntp = 1;
for(int j = 0;j < x[i].size();j++){
if(chk[i][j]){
s[i][j] = cnt;
cnt += cntp;
}
}
}
allocate_tickets(s);
return ret;
}
Compilation message (stderr)
tickets.cpp: In function 'long long int find_maximum(int, std::vector<std::vector<int> >)':
tickets.cpp:8:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
8 | for(int i = 0;i < s.size();i++) s[i].resize(x[0].size(), -1);
| ~~^~~~~~~~~~
tickets.cpp:12:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
12 | for(int i = 0;i < x.size();i++){
| ~~^~~~~~~~~~
tickets.cpp:20:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
20 | for(int i = 0;i < k*x.size()/2;i++){
| ~~^~~~~~~~~~~~~~
tickets.cpp:30:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
30 | for(int i = 0;i < x.size();i++){
| ~~^~~~~~~~~~
tickets.cpp:33:25: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
33 | for(int j = 0;j < x[i].size();j++){
| ~~^~~~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |