Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- #include <algorithm>
- #include <string>
- #include <set>
- #include <map>
- #include <stack>
- #include <queue>
- #include <cmath>
- #include <climits>
- #include <iomanip>
- #include <cassert>
- #include <fstream>
- #include <sstream>
- #include <unordered_map>
- #include <unordered_set>
- #include <bitset>
- #include <random>
- #include <chrono>
- #include <functional>
- #include <numeric>
- #include <complex>
- #include <array>
- #include <tuple>
- #include <valarray>
- #include <memory>
- #include <limits>
- #include <cctype>
- #include <cstring>
- #include <cstdio>
- #include <cstdlib>
- #include <ctime>
- #include <cassert>
- #include <climits>
- #include <cfloat>
- #include <cstdarg>
- #include <cstddef>
- #include <cstdint>
- #include <cwchar>
- #include <cwctype>
- #include <exception>
- #include <stdexcept>
- #include <typeinfo>
- #include <utility>
- #include <new>
- #include <type_traits>
- #include <initializer_list>
- #include <iterator>
- #include <limits>
- // #include <bits/stdc++.h>
- using namespace std;
- bool pairsorterhelper(const pair<int, int> &a, const pair<int, int> &b) {
- if (a.first == b.first) return a.second > b.second;
- return a.first < b.first;
- }
- int main(void) {
- int n;
- cin >> n;
- vector<pair<int, int> > a(n);
- for (int i = 0; i < n; i++) cin >> a[i].first;
- for (int i = 0; i < n; i++) cin >> a[i].second;
- sort(a.begin(), a.end(), pairsorterhelper);
- int count = 0, index = 0;
- int i = 0;
- for (i = 0; i < n; i++) {
- cout << a[i].first << " " << a[i].second << '\n';
- }
- i = 0;
- cout << '\n';
- cout << "------------------" << '\n';
- cout << '\n';
- while (index < n && i < a[n-1].first) {
- ++i;
- while (index < n && a[index].first < i) ++index;
- if (a[index].first >= i) {
- count+=a[index].second;
- cout << a[index].first << " " << a[index].second << '\n';
- }
- ++index;
- }
- cout << count << '\n';
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement