이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
//https://www.instagram.com/_modwwe/
#include "tickets.h"
#pragma GCC optimize("Ofast,unroll-loops")
#include<bits/stdc++.h>
//#define int long long
#define ll long long
#define down cout<<'\n';
#define debug cout<<" cucuucucuuu",down
#define NHP ios_base::sync_with_stdio(0);cout.tie(0);cin.tie(0);
#define modwwe int t;cin>>t; while(t--)
#define bit(i,j) (i>>j&1)
#define sobit(a) __builtin_popcountll(a)
#define task "test"
#define fin(x) freopen(x".inp","r",stdin)
#define fou(x) freopen(x".ans","w",stdout)
#define pb push_back
#define checktime cerr << (double)clock() / CLOCKS_PER_SEC * 1000 << " ms";
using namespace std;
void phongbeo();
const int inf=1e9;
const int mod2=1e9+7;
const int mod1=998244353;
struct icd
{
long double a;
int b;
};
struct ib
{
int a;
int b;
};
struct ic
{
ll a,b,c;
};
struct id
{
int a,b,c,d;
};
struct ie
{
int a,b,c,d,e;
};
ll n,m,s1,s2,s4,s3,sf,k,s5,s6,mx,s7,s8,s9,mx2,res,dem2=0,dem=0,s33,dem3,l,r,mid;
int i,s10,s12;
int kk;
int el=29;
struct cmp
{
bool operator()(ic a,ic b)
{
return a.a<b.a;
}
};
priority_queue<ic,vector<ic>,cmp>p;
int f[1507];
bool g[1507];
long long find_maximum(int k, std::vector<std::vector<int>> a)
{
/// cin>>n>>m>>k;
n=a.size();
m=a[0].size();
vector<vector<int>> ans(n,vector<int>(m,-1));
for(int i=1; i<=n; i++)
for(int j=1; j<=k; j++)
s4-=a[i-1][j-1];
for(int i=1; i<=n; i++)
p.push({a[i-1][m-1]+a[i-1][k-1],i,0});
for(int i=1; i<=n*k/2; i++)
{
ic x=p.top();
p.pop();
s4+=x.a;
x.c++;
f[x.b]=x.c;
if(x.c==k) continue;
p.push({a[x.b-1][m-x.c-1]+a[x.b-1][k-x.c-1],x.b,x.c});
}
s2=1;
for(int i=1; i<=n; i++)
{
l=k-f[i];
r=m-f[i]+1;
for(int j=1;j<=f[i];j++)
{
s3=s2%k;
if(s3==0)s3=k;
ans[i-1][r-1]=s3-1;
r++;
g[s3]=1;
s2++;
}
for(int j=1;j<=k;j++)
{
if(g[j]) {g[j]=0;continue;}
ans[i-1][l-1]=j-1,l--;
}
}
allocate_tickets(ans);
return s4;
}
/*
main()
{
#ifndef ONLINE_JUDGE
fin(task),fou(task);
#endif
NHP
/// cin>>s1;
// modwwe
phongbeo();
}
int a[1501][1501];
void phongbeo(){
cin>>n>>m>>k;
vector<vector<int>> x;
x.resize(n, vector<int> (m));
for(int i=1;i<=n;i++)
for(int j=1;j<=m;j++)
cin>>a[i][j];
for(int i=1;i<=n;i++)
{
sort(a[i]+1,a[i]+1+m);
for(int j=1;j<=m;j++)
x[i-1][j-1]=a[i][j];
}
cout<<find_maximum(k,x);
}
*/
# | 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... |