이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define pb push_back
#define endl '\n'
#define conts continue
#define sz(a) (int)a.size()
#define ff first
#define ss second
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) for(int i = 0; i < n; ++i)
#define rep1(i,n) for(int i = 1; i <= n; ++i)
#define rev(i,s,e) for(int i = s; i >= e; ++i)
#define trav(i,a) for(auto &i : a)
template<typename T>
void amin(T &x, T y){
x = min(x,y);
}
template<typename T>
void amax(T &x, T y){
x = max(x,y);
}
template<typename A,typename B>
string to_string(pair<A,B> p);
string to_string(const string &s){
return "'"+s+"'";
}
string to_string(const char* s){
return to_string((string)s);
}
string to_string(bool b){
return b?"true":"false";
}
template<typename A>
string to_string(A v){
string res = "{";
trav(x,v){
res += to_string(x)+",";
}
if(res.back() == ',') res.pop_back();
res += "}";
return res;
}
template<typename A,typename B>
string to_string(pair<A,B> p){
return "("+to_string(p.ff)+","+to_string(p.ss)+")";
}
#define debug(x) cout << "[" << #x << "]: "; cout << to_string(x) << endl
/*
refs:
edi
*/
const int MOD = 1e9 + 7;
const int N = 1e5 + 5;
const int inf1 = 1e9 + 5;
const ll inf2 = (ll)1e18 + 5;
#include "tickets.h"
long long find_maximum(int k, std::vector<std::vector<int>> a) {
int n = a.size();
int m = a[0].size();
vector<vector<int>> ans(n,vector<int>(m,-1));
ll cost = 0;
vector<array<int,3>> vals;
rep(i,n) rep(j,m) vals.pb({a[i][j],i,j});
sort(all(vals));
vector<int> pos[n], neg[n];
rep(ind,sz(vals)){
auto [x,i,j] = vals[ind];
if(ind < sz(vals)/2){
neg[i].pb(j);
cost -= x;
}
else{
pos[i].pb(j);
cost += x;
}
}
vector<bool> done(n);
rep(x,k){
int pc = 0, nc = 0;
fill(all(done),0);
rep(i,n){
int j = -1;
if(pos[i].empty()){
nc++;
j = neg[i].back();
neg[i].pop_back();
}
else if(neg[i].empty()){
pc++;
j = pos[i].back();
pos[i].pop_back();
}
if(j != -1){
a[i][j] = x;
done[i] = 1;
}
}
rep(i,n){
if(done[i]) conts;
int j = -1;
if(pc < n/2){
pc++;
j = pos[i].back();
pos[i].pop_back();
}
else{
nc++;
j = neg[i].back();
neg[i].pop_back();
}
a[i][j] = x;
}
}
allocate_tickets(a);
return cost;
// std::vector<std::vector<int>> answer;
// for (int i = 0; i < n; i++) {
// std::vector<int> row(m);
// for (int j = 0; j < m; j++) {
// if (j < k) {
// row[j] = j;
// } else {
// row[j] = -1;
// }
// }
// answer.push_back(row);
// }
// allocate_tickets(answer);
// return 1;
}
# | 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... |