10465 | 2024-04-02 23:59:01 | 111 | Walking In The Park | cpp17 | Wrong answer 0/100 | 112ms | 17712 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;
}
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());
}
if(ans.size()>K){
ans.resize(K);
}
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 | 1976 KiB | ||||
2 | Accepted | 3ms | 2184 KiB | ||||
subtask2 | 0/19 | ||||||
3 | Wrong answer | 63ms | 11584 KiB | ||||
4 | Wrong answer | 65ms | 12356 KiB | ||||
5 | Wrong answer | 71ms | 14000 KiB | ||||
6 | Accepted | 64ms | 13080 KiB | ||||
7 | Accepted | 71ms | 14172 KiB | ||||
8 | Accepted | 65ms | 13348 KiB | ||||
9 | Wrong answer | 81ms | 16224 KiB | ||||
subtask3 | 0/23 | ||||||
10 | Wrong answer | 3ms | 3300 KiB | ||||
11 | Wrong answer | 3ms | 3296 KiB | ||||
12 | Accepted | 3ms | 3432 KiB | ||||
13 | Accepted | 3ms | 3652 KiB | ||||
14 | Accepted | 3ms | 3640 KiB | ||||
15 | Wrong answer | 3ms | 3772 KiB | ||||
subtask4 | 0/16 | ||||||
16 | Wrong answer | 3ms | 4144 KiB | ||||
17 | Wrong answer | 3ms | 4100 KiB | ||||
18 | Wrong answer | 3ms | 4096 KiB | ||||
19 | Accepted | 3ms | 4356 KiB | ||||
20 | Accepted | 3ms | 4568 KiB | ||||
21 | Accepted | 3ms | 4520 KiB | ||||
22 | Wrong answer | 3ms | 4596 KiB | ||||
subtask5 | 0/42 | ||||||
23 | Wrong answer | 96ms | 13820 KiB | ||||
24 | Wrong answer | 97ms | 14460 KiB | ||||
25 | Wrong answer | 104ms | 15848 KiB | ||||
26 | Accepted | 100ms | 14844 KiB | ||||
27 | Accepted | 107ms | 16044 KiB | ||||
28 | Accepted | 98ms | 14988 KiB | ||||
29 | Wrong answer | 112ms | 17712 KiB |