Submission #1293881

#TimeUsernameProblemLanguageResultExecution timeMemory
1293881akmuhammet_sA Plus B (IOI23_aplusb)C++20
10 / 100
1 ms344 KiB
#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=0;
	priority_queue<pair<int,pair<int,int> >,vector<pair<int,pair<int,int> > >,greater<pair<int,pair<int,int> > > > pq;
	pq.push({a[0]+b[0],{0,0}});
	while(k<n){
		pair<int,pair<int,int> > pp=pq.top();
		pq.pop();
		ans.pb(pp.first);
		k++;
		if(pp.ss.ff+1<n){
			pq.push({a[pp.ss.ff+1]+b[pp.ss.ss],{pp.ss.ff+1,pp.ss.ss}});
		}
		if(pp.ss.ss+1<n){
			pq.push({a[pp.ss.ff]+b[pp.ss.ss+1],{pp.ss.ff,pp.ss.ss+1}});
		}
	}
	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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...