# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1055776 |
2024-08-13T05:13:59 Z |
d(#11110) |
Pizza Party (CCO24_day1problem2) |
C++17 |
|
567 ms |
88536 KB |
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define debug(...)
#endif
using pii=array<int,2>;
using tii=array<int,3>;
const int N=1000005;
int n,a[N],b[N],cnt[N],k,ans[N];
tii v[N];
set<pii,greater<pii>> S;
int main(){
ios::sync_with_stdio(false); cin.tie(0);
cin>>n;
for(int i=1;i<=n;i++){
cin>>a[i];
cnt[a[i]]++;
v[a[i]][0]=i;
}
for(int i=1;i<=n;i++){
cin>>b[i];
cnt[b[i]]--;
if(cnt[b[i]]<0){
cout<<"-1\n";
return 0;
}
v[b[i]][1]=n+1-i;
}
for(int i=1;i<=n;i++) v[i][2]=i;
sort(v+1,v+n+1);
for(int i=1;i<=n;i++){
int val=v[i][1];
auto iter=S.lower_bound({val,-1});
if(iter==S.end()){
k++;
S.insert({val,k});
ans[v[i][2]]=k;
continue;
}
int g=(*iter)[1];
S.erase(iter);
S.insert({val,g});
ans[v[i][2]]=g;
}
cout<<k<<"\n";
for(int i=1;i<=n;i++) cout<<ans[a[i]]<<" \n"[i==n];
for(int i=1;i<=n;i++) cout<<ans[b[i]]<<" \n"[i==n];
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
510 ms |
84748 KB |
jury uses fewer stacks: jans = 2, pans = 999998 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
604 KB |
good job! |
2 |
Correct |
1 ms |
348 KB |
good job! |
3 |
Correct |
2 ms |
648 KB |
good job! |
4 |
Correct |
1 ms |
564 KB |
good job! |
5 |
Correct |
2 ms |
604 KB |
good job! |
6 |
Correct |
1 ms |
564 KB |
good job! |
7 |
Correct |
0 ms |
348 KB |
good job! |
8 |
Correct |
2 ms |
604 KB |
good job! |
9 |
Correct |
2 ms |
604 KB |
good job! |
10 |
Correct |
2 ms |
604 KB |
good job! |
11 |
Correct |
2 ms |
860 KB |
good job! |
12 |
Correct |
1 ms |
604 KB |
good job! |
13 |
Correct |
2 ms |
860 KB |
good job! |
14 |
Correct |
2 ms |
604 KB |
good job! |
15 |
Correct |
1 ms |
344 KB |
good job! |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
477 ms |
36620 KB |
good job! |
2 |
Correct |
85 ms |
20304 KB |
good job! |
3 |
Correct |
464 ms |
36600 KB |
good job! |
4 |
Correct |
111 ms |
21844 KB |
good job! |
5 |
Correct |
479 ms |
36692 KB |
good job! |
6 |
Correct |
92 ms |
21328 KB |
good job! |
7 |
Correct |
113 ms |
21840 KB |
good job! |
8 |
Correct |
455 ms |
36688 KB |
good job! |
9 |
Correct |
471 ms |
36476 KB |
good job! |
10 |
Correct |
450 ms |
36560 KB |
good job! |
11 |
Correct |
564 ms |
88536 KB |
good job! |
12 |
Correct |
329 ms |
31680 KB |
good job! |
13 |
Correct |
567 ms |
88500 KB |
good job! |
14 |
Correct |
342 ms |
31824 KB |
good job! |
15 |
Correct |
111 ms |
22608 KB |
good job! |
16 |
Correct |
112 ms |
22608 KB |
good job! |