This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#pragma GCC optimization "O2"
#pragma GCC optimization "unroll-loop"
#pragma GCC target ("avx2")
#include "tickets.h"
#include <bits/stdc++.h>
#define ll int
#define ld long double
#define fs first
#define sc second
using namespace std;
const ll N = 1500 + 9;
const ll inf = 1e9 + 7;
typedef pair<ll,ll> LL;
long long kq;
ll n,m,k,big[N],sm[N],trade[N];
priority_queue<LL,vector<LL>,greater<LL>> pq;
long long find_maximum(ll k, vector<vector<ll>> a){
n = a.size(); m = a[0].size();
vector<vector<ll>> ans;
ans.resize(n);
for (ll i = 0;i < ans.size();i++){
ans[i].resize(m);
for (ll j = 0;j < ans[i].size();j++) ans[i][j] = -1;
for (ll j = m - k;j < ans[i].size();j++){
kq += a[i][j]; ans[i][j] = j - (m - k);
}
big[i] = m - k; sm[i] = 0;
pq.push({a[i][m - k] + a[i][0],i});
}
ll cnt = n*k/2;
while(cnt--){
LL now = pq.top(); pq.pop();
if (trade[now.sc] >= k) continue;
trade[now.sc]++;
ll i = now.sc;
ans[i][sm[i]] = ans[i][big[i]]; ans[i][big[i]] = -1;
kq -= now.fs; big[i]++; sm[i]++;
pq.push({a[i][big[i]] + a[i][sm[i]],i});
}
allocate_tickets(ans);
return kq;
}
Compilation message (stderr)
tickets.cpp:1: warning: ignoring '#pragma GCC optimization' [-Wunknown-pragmas]
1 | #pragma GCC optimization "O2"
|
tickets.cpp:2: warning: ignoring '#pragma GCC optimization' [-Wunknown-pragmas]
2 | #pragma GCC optimization "unroll-loop"
|
tickets.cpp: In function 'long long int find_maximum(int, std::vector<std::vector<int> >)':
tickets.cpp:23:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
23 | for (ll i = 0;i < ans.size();i++){
| ~~^~~~~~~~~~~~
tickets.cpp:25:25: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
25 | for (ll j = 0;j < ans[i].size();j++) ans[i][j] = -1;
| ~~^~~~~~~~~~~~~~~
tickets.cpp:26:29: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
26 | for (ll j = m - k;j < ans[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... |