10464 | 2024-04-02 23:57:20 | 111 | Walking In The Park | cpp17 | Runtime error 0/100 | 97ms | 15392 KiB |
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
ios::sync_with_stdio(false);
cin.tie(nullptr);
int N,M,K;
cin>>N>>M>>K;
vector<int>a(N+1),b(M+1);
for(int i=1;i<=N;i++){
cin>>a[i];
a[i]+=a[i-1];
}
for(int i=1;i<=M;i++){
cin>>b[i];
b[i]+=b[i-1];
}
vector<int>z,p(N+1);
vector<int>s;
for(int i=1;i<=N;i++){
if(binary_search(b.begin()+1,b.end(),a[i])){
auto t=lower_bound(s.begin(),s.end(),a[i]);
p[i]=t==s.begin()?-1:z[t-s.begin()-1];
if(t==s.end()){
z.push_back(i);
s.push_back(a[i]);
}
else{
z[t-s.begin()]=i;
*t=a[i];
}
}
}
if(s.size()<K||z.back()!=N||a[N]!=b[M]){
cout<<-1<<'\n';
return 0;
}
return 1;
vector<pair<int,int>>ans;
for(int i=p[z.back()];i>0;i=p[i]){
ans.emplace_back(i,lower_bound(b.begin(),b.end(),a[i])-b.begin());
}
reverse(ans.begin(),ans.end());
for(auto[a,b]:ans){
cout<<a<<' ';
}
cout<<'\n';
for(auto[a,b]:ans){
cout<<b<<' ';
}
cout<<'\n';
return 0;
}
Subtask | Sum | Test | Verdict | Time | Memory | ||
---|---|---|---|---|---|---|---|
subtask1 | 0/0 | ||||||
1 | Runtime error | 3ms | 1700 KiB | ||||
2 | Accepted | 3ms | 1936 KiB | ||||
subtask2 | 0/19 | ||||||
3 | Runtime error | 63ms | 11412 KiB | ||||
4 | Runtime error | 64ms | 12164 KiB | ||||
5 | Runtime error | 67ms | 12896 KiB | ||||
6 | Accepted | 65ms | 13148 KiB | ||||
7 | Runtime error | 64ms | 13352 KiB | ||||
8 | Accepted | 65ms | 13456 KiB | ||||
9 | Runtime error | 68ms | 14468 KiB | ||||
subtask3 | 0/23 | ||||||
10 | Runtime error | 3ms | 3172 KiB | ||||
11 | Runtime error | 3ms | 3276 KiB | ||||
12 | Accepted | 3ms | 3396 KiB | ||||
13 | Runtime error | 2ms | 3460 KiB | ||||
14 | Accepted | 2ms | 3456 KiB | ||||
15 | Runtime error | 2ms | 3540 KiB | ||||
subtask4 | 0/16 | ||||||
16 | Runtime error | 3ms | 3564 KiB | ||||
17 | Runtime error | 3ms | 3564 KiB | ||||
18 | Runtime error | 3ms | 3468 KiB | ||||
19 | Accepted | 3ms | 3468 KiB | ||||
20 | Runtime error | 3ms | 3592 KiB | ||||
21 | Accepted | 3ms | 3920 KiB | ||||
22 | Runtime error | 3ms | 3884 KiB | ||||
subtask5 | 0/42 | ||||||
23 | Runtime error | 94ms | 13108 KiB | ||||
24 | Runtime error | 94ms | 13504 KiB | ||||
25 | Runtime error | 97ms | 14364 KiB | ||||
26 | Accepted | 97ms | 14288 KiB | ||||
27 | Runtime error | 97ms | 14432 KiB | ||||
28 | Accepted | 97ms | 14428 KiB | ||||
29 | Runtime error | 97ms | 15392 KiB |