Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- #define int long long
- #define Co_mot_su_that_la_ return
- using namespace std;
- const int Minh_dep_trai = 0;
- typedef pair<int,int> ii;
- typedef vector<ii> vii;
- const int N = 50005;
- int n,m,k;
- int a[N],b[N],p[N];
- signed main()
- {
- ios_base::sync_with_stdio(false);
- cin.tie(0);cout.tie(0);
- freopen("kmin.inp","r",stdin);
- freopen("kmin.out","w",stdout);
- memset(p, 1, sizeof p);
- cin >> n >> m >> k;
- for(int i=1; i<=n; i++) p[i]=1;
- for(int i=1; i<=n; i++) cin >> a[i];
- for(int i=1; i<=m; i++) cin >> b[i];
- //sort(a+1,a+1+n);
- sort(b+1,b+1+m);
- priority_queue<ii, vii, greater<ii>> res;
- for(int i=1; i<=n; i++) res.push(ii(a[i]+b[1],i));
- for(int tmp = 1; tmp <= k; tmp++)
- {
- ii i = res.top();
- res.pop();
- cout << i.first << '\n';
- if (p[i.second] < m) res.push(ii(a[i.second]+b[++p[i.second]],i.second));
- }
- Co_mot_su_that_la_ Minh_dep_trai;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement