104642024-04-02 23:57:20111Walking In The Parkcpp17Runtime error 0/10097ms15392 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;
}
SubtaskSumTestVerdictTimeMemory
subtask10/0
1Runtime error3ms1700 KiB
2Accepted3ms1936 KiB
subtask20/19
3Runtime error63ms11412 KiB
4Runtime error64ms12164 KiB
5Runtime error67ms12896 KiB
6Accepted65ms13148 KiB
7Runtime error64ms13352 KiB
8Accepted65ms13456 KiB
9Runtime error68ms14468 KiB
subtask30/23
10Runtime error3ms3172 KiB
11Runtime error3ms3276 KiB
12Accepted3ms3396 KiB
13Runtime error2ms3460 KiB
14Accepted2ms3456 KiB
15Runtime error2ms3540 KiB
subtask40/16
16Runtime error3ms3564 KiB
17Runtime error3ms3564 KiB
18Runtime error3ms3468 KiB
19Accepted3ms3468 KiB
20Runtime error3ms3592 KiB
21Accepted3ms3920 KiB
22Runtime error3ms3884 KiB
subtask50/42
23Runtime error94ms13108 KiB
24Runtime error94ms13504 KiB
25Runtime error97ms14364 KiB
26Accepted97ms14288 KiB
27Runtime error97ms14432 KiB
28Accepted97ms14428 KiB
29Runtime error97ms15392 KiB