10461 | 2024-04-02 23:52:18 | 111 | Walking In The Park | cpp17 | Wrong answer 0/100 | 554ms | 523228 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]=s.empty()?-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){
cout<<-1<<'\n';
return 0;
}
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 | Accepted | 3ms | 1828 KiB | ||||
2 | Accepted | 3ms | 2080 KiB | ||||
subtask2 | 0/19 | ||||||
3 | Wrong answer | 68ms | 11464 KiB | ||||
4 | Wrong answer | 68ms | 12568 KiB | ||||
5 | Wrong answer | 74ms | 14168 KiB | ||||
6 | Accepted | 70ms | 12996 KiB | ||||
7 | Accepted | 75ms | 14256 KiB | ||||
8 | Wrong answer | 75ms | 14220 KiB | ||||
9 | Wrong answer | 86ms | 16056 KiB | ||||
subtask3 | 0/23 | ||||||
10 | Wrong answer | 3ms | 3280 KiB | ||||
11 | Runtime error | 335ms | 523228 KiB | ||||
12 | Accepted | 3ms | 3832 KiB | ||||
13 | Accepted | 3ms | 3912 KiB | ||||
14 | Runtime error | 400ms | 523000 KiB | ||||
15 | Runtime error | 337ms | 522968 KiB | ||||
subtask4 | 0/16 | ||||||
16 | Wrong answer | 3ms | 3856 KiB | ||||
17 | Wrong answer | 3ms | 3876 KiB | ||||
18 | Runtime error | 430ms | 522732 KiB | ||||
19 | Accepted | 3ms | 4092 KiB | ||||
20 | Runtime error | 435ms | 522720 KiB | ||||
21 | Wrong answer | 3ms | 4120 KiB | ||||
22 | Runtime error | 421ms | 522724 KiB | ||||
subtask5 | 0/42 | ||||||
23 | Wrong answer | 101ms | 13472 KiB | ||||
24 | Runtime error | 526ms | 522444 KiB | ||||
25 | Runtime error | 524ms | 522428 KiB | ||||
26 | Accepted | 104ms | 14912 KiB | ||||
27 | Runtime error | 554ms | 522200 KiB | ||||
28 | Wrong answer | 108ms | 16016 KiB | ||||
29 | Runtime error | 513ms | 522120 KiB |