#include "bits/stdc++.h"
using namespace std;
#define mod 1000000007
#define ll long long
#define ff first
#define ss second
#define pb push_back
#define N 24
#define maxn 2000005
vector<int> smallest_sums(int n,vector<int> a,vector<int> b){
vector<int> ans;
int i=0,j=0,k=1;
ans.pb(a[i]+b[j]);
while(k<n){
if(a[i+1]<b[j+1]){
i++;
for(int x=0; x<=j; x++){
if(k==n) break;
k++;
ans.pb(a[i]+b[x]);
}
}else{
j++;
for(int x=0; x<=i; x++){
if(k==n) break;
k++;
ans.pb(a[x]+b[j]);
}
}
}
return ans;
}
// void solve(){
// int n;
// vector<int> a,b;
// cin>>n;
// for(int i=1; i<=n; i++){
// int x;
// cin>>x;
// a.pb(x);
// }
// for(int i=1; i<=n; i++){
// int x;
// cin>>x;
// b.pb(x);
// }
// vector<int> ans=smallest_sums(n,a,b);
// for(int i=0; i<ans.size(); i++) cout<<ans[i]<<' ';
// }
//
// int main(){
// // freopen("in.txt","w",stdout);
// // freopen("out.txt","r",stdin);
// ios_base::sync_with_stdio(0); cin.tie(0);
// int t=1;
// // cin>>t;
// while(t--) solve();
// }
//
// 4
// 2 2 2 2
// 2 3 3 3
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |