Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- typedef long long lli;
- const int N = 5e5;
- lli people[N + 1], stage[N + 1];
- int nSeq;
- int main(){
- scanf("%d", &nSeq);
- for(int i = 1; i <= nSeq; ++i){
- scanf("%lld", &people[i]);
- }
- for(int i = 1; i <= nSeq; ++i){
- scanf("%lld", &stage[i]);
- }
- sort(people + 1, people + nSeq + 1);
- sort(stage + 1, stage + nSeq + 1, greater<lli>());
- for(int i = 1; i <= nSeq; ++i){
- stage[i] += people[i];
- }
- sort(stage + 1, stage + nSeq + 1);
- lli sum = 0;
- for(int i = 1; i < nSeq; ++i){
- sum += stage[i + 1] - stage[i];
- }
- cout << sum;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement