# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1055871 |
2024-08-13T06:12:22 Z |
4321(#11112) |
Pizza Party (CCO24_day1problem2) |
C++17 |
|
715 ms |
85244 KB |
#include<bits/stdc++.h>
using namespace std;
#define fast ios::sync_with_stdio(false); cin.tie(NULL);
#define fi first
#define se second
#define em emplace
#define eb emplace_back
#define all(v) (v).begin(), (v).end()
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int inf = 1e9;
const ll INF = 1e18;
int n;
vector<int> g[1000010];
int a[1000010];
int b[1000010];
int main() {
fast;
cin >> n;
for(int i=1; i<=n; i++) {
int x;
cin >> x;
g[x].eb(i);
}
set<pii> S;
for(int i=1; i<=n; i++) {
int x;
cin >> x;
if(g[x].empty()) {
cout << -1;
return 0;
}
int y = g[x].back();
g[x].pop_back();
auto it = S.lower_bound(mp(y, 0));
int c = S.size()+1;
if(it != S.end()) {
c = it->se;
S.erase(it);
}
a[y] = b[i] = c;
S.insert(mp(y, c));
}
cout << S.size() << "\n";
for(int i=1; i<=n; i++) cout << a[i] << " ";
cout << "\n";
for(int i=1; i<=n; i++) cout << b[i] << " ";
cout << "\n";
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
181 ms |
39752 KB |
Expected EOLN |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
11 ms |
24200 KB |
Expected EOLN |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
715 ms |
85244 KB |
Expected EOLN |
2 |
Halted |
0 ms |
0 KB |
- |