//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 |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
444 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
860 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
452 KB |
Output is correct |
5 |
Correct |
17 ms |
3160 KB |
Output is correct |
6 |
Correct |
322 ms |
73164 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
2 ms |
604 KB |
Output is correct |
5 |
Correct |
12 ms |
2692 KB |
Output is correct |
6 |
Correct |
295 ms |
56928 KB |
Output is correct |
7 |
Correct |
285 ms |
57124 KB |
Output is correct |
8 |
Correct |
2 ms |
604 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
3 ms |
856 KB |
Output is correct |
13 |
Correct |
10 ms |
2140 KB |
Output is correct |
14 |
Correct |
10 ms |
2140 KB |
Output is correct |
15 |
Correct |
290 ms |
57680 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
2 ms |
604 KB |
Output is correct |
5 |
Correct |
17 ms |
3420 KB |
Output is correct |
6 |
Correct |
3 ms |
860 KB |
Output is correct |
7 |
Correct |
4 ms |
1116 KB |
Output is correct |
8 |
Correct |
435 ms |
75944 KB |
Output is correct |
9 |
Correct |
401 ms |
71080 KB |
Output is correct |
10 |
Correct |
397 ms |
71076 KB |
Output is correct |
11 |
Correct |
439 ms |
76240 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
452 KB |
Output is correct |
3 |
Correct |
2 ms |
604 KB |
Output is correct |
4 |
Correct |
2 ms |
604 KB |
Output is correct |
5 |
Correct |
1 ms |
452 KB |
Output is correct |
6 |
Correct |
2 ms |
604 KB |
Output is correct |
7 |
Correct |
0 ms |
440 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
452 KB |
Output is correct |
10 |
Correct |
2 ms |
452 KB |
Output is correct |
11 |
Correct |
2 ms |
600 KB |
Output is correct |
12 |
Correct |
2 ms |
604 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
452 KB |
Output is correct |
3 |
Correct |
2 ms |
604 KB |
Output is correct |
4 |
Correct |
2 ms |
604 KB |
Output is correct |
5 |
Correct |
1 ms |
452 KB |
Output is correct |
6 |
Correct |
2 ms |
604 KB |
Output is correct |
7 |
Correct |
0 ms |
440 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
452 KB |
Output is correct |
10 |
Correct |
2 ms |
452 KB |
Output is correct |
11 |
Correct |
2 ms |
600 KB |
Output is correct |
12 |
Correct |
2 ms |
604 KB |
Output is correct |
13 |
Correct |
14 ms |
3160 KB |
Output is correct |
14 |
Correct |
15 ms |
3164 KB |
Output is correct |
15 |
Correct |
15 ms |
3416 KB |
Output is correct |
16 |
Correct |
17 ms |
3420 KB |
Output is correct |
17 |
Correct |
1 ms |
344 KB |
Output is correct |
18 |
Correct |
2 ms |
600 KB |
Output is correct |
19 |
Correct |
1 ms |
352 KB |
Output is correct |
20 |
Correct |
12 ms |
2800 KB |
Output is correct |
21 |
Correct |
15 ms |
3272 KB |
Output is correct |
22 |
Correct |
14 ms |
2656 KB |
Output is correct |
23 |
Correct |
16 ms |
3168 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
444 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
860 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
452 KB |
Output is correct |
11 |
Correct |
17 ms |
3160 KB |
Output is correct |
12 |
Correct |
322 ms |
73164 KB |
Output is correct |
13 |
Correct |
1 ms |
348 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
2 ms |
604 KB |
Output is correct |
17 |
Correct |
12 ms |
2692 KB |
Output is correct |
18 |
Correct |
295 ms |
56928 KB |
Output is correct |
19 |
Correct |
285 ms |
57124 KB |
Output is correct |
20 |
Correct |
2 ms |
604 KB |
Output is correct |
21 |
Correct |
1 ms |
348 KB |
Output is correct |
22 |
Correct |
1 ms |
348 KB |
Output is correct |
23 |
Correct |
0 ms |
348 KB |
Output is correct |
24 |
Correct |
3 ms |
856 KB |
Output is correct |
25 |
Correct |
10 ms |
2140 KB |
Output is correct |
26 |
Correct |
10 ms |
2140 KB |
Output is correct |
27 |
Correct |
290 ms |
57680 KB |
Output is correct |
28 |
Correct |
0 ms |
344 KB |
Output is correct |
29 |
Correct |
0 ms |
348 KB |
Output is correct |
30 |
Correct |
0 ms |
348 KB |
Output is correct |
31 |
Correct |
2 ms |
604 KB |
Output is correct |
32 |
Correct |
17 ms |
3420 KB |
Output is correct |
33 |
Correct |
3 ms |
860 KB |
Output is correct |
34 |
Correct |
4 ms |
1116 KB |
Output is correct |
35 |
Correct |
435 ms |
75944 KB |
Output is correct |
36 |
Correct |
401 ms |
71080 KB |
Output is correct |
37 |
Correct |
397 ms |
71076 KB |
Output is correct |
38 |
Correct |
439 ms |
76240 KB |
Output is correct |
39 |
Correct |
0 ms |
348 KB |
Output is correct |
40 |
Correct |
1 ms |
452 KB |
Output is correct |
41 |
Correct |
2 ms |
604 KB |
Output is correct |
42 |
Correct |
2 ms |
604 KB |
Output is correct |
43 |
Correct |
1 ms |
452 KB |
Output is correct |
44 |
Correct |
2 ms |
604 KB |
Output is correct |
45 |
Correct |
0 ms |
440 KB |
Output is correct |
46 |
Correct |
0 ms |
348 KB |
Output is correct |
47 |
Correct |
1 ms |
452 KB |
Output is correct |
48 |
Correct |
2 ms |
452 KB |
Output is correct |
49 |
Correct |
2 ms |
600 KB |
Output is correct |
50 |
Correct |
2 ms |
604 KB |
Output is correct |
51 |
Correct |
14 ms |
3160 KB |
Output is correct |
52 |
Correct |
15 ms |
3164 KB |
Output is correct |
53 |
Correct |
15 ms |
3416 KB |
Output is correct |
54 |
Correct |
17 ms |
3420 KB |
Output is correct |
55 |
Correct |
1 ms |
344 KB |
Output is correct |
56 |
Correct |
2 ms |
600 KB |
Output is correct |
57 |
Correct |
1 ms |
352 KB |
Output is correct |
58 |
Correct |
12 ms |
2800 KB |
Output is correct |
59 |
Correct |
15 ms |
3272 KB |
Output is correct |
60 |
Correct |
14 ms |
2656 KB |
Output is correct |
61 |
Correct |
16 ms |
3168 KB |
Output is correct |
62 |
Correct |
37 ms |
8536 KB |
Output is correct |
63 |
Correct |
36 ms |
8528 KB |
Output is correct |
64 |
Correct |
46 ms |
8528 KB |
Output is correct |
65 |
Correct |
167 ms |
33216 KB |
Output is correct |
66 |
Correct |
194 ms |
33544 KB |
Output is correct |
67 |
Correct |
4 ms |
924 KB |
Output is correct |
68 |
Correct |
3 ms |
860 KB |
Output is correct |
69 |
Correct |
321 ms |
73044 KB |
Output is correct |
70 |
Correct |
378 ms |
74068 KB |
Output is correct |
71 |
Correct |
423 ms |
76116 KB |
Output is correct |
72 |
Correct |
315 ms |
60700 KB |
Output is correct |
73 |
Correct |
417 ms |
73436 KB |
Output is correct |
74 |
Correct |
301 ms |
59188 KB |
Output is correct |
75 |
Correct |
403 ms |
71764 KB |
Output is correct |