104612024-04-02 23:52:18111Walking In The Parkcpp17Wrong answer 0/100554ms523228 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;
}
SubtaskSumTestVerdictTimeMemory
subtask10/0
1Accepted3ms1828 KiB
2Accepted3ms2080 KiB
subtask20/19
3Wrong answer68ms11464 KiB
4Wrong answer68ms12568 KiB
5Wrong answer74ms14168 KiB
6Accepted70ms12996 KiB
7Accepted75ms14256 KiB
8Wrong answer75ms14220 KiB
9Wrong answer86ms16056 KiB
subtask30/23
10Wrong answer3ms3280 KiB
11Runtime error335ms523228 KiB
12Accepted3ms3832 KiB
13Accepted3ms3912 KiB
14Runtime error400ms523000 KiB
15Runtime error337ms522968 KiB
subtask40/16
16Wrong answer3ms3856 KiB
17Wrong answer3ms3876 KiB
18Runtime error430ms522732 KiB
19Accepted3ms4092 KiB
20Runtime error435ms522720 KiB
21Wrong answer3ms4120 KiB
22Runtime error421ms522724 KiB
subtask50/42
23Wrong answer101ms13472 KiB
24Runtime error526ms522444 KiB
25Runtime error524ms522428 KiB
26Accepted104ms14912 KiB
27Runtime error554ms522200 KiB
28Wrong answer108ms16016 KiB
29Runtime error513ms522120 KiB