Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // LUNCHBOX
- #include <iostream>
- #include <cstring>
- using namespace std;
- #include <fstream>
- #include <cstdio>
- #include <cmath>
- #include <ctime>
- #include <vector>
- #include <stack>
- #include <queue>
- #include <functional>
- #include <deque>
- #include <numeric>
- #include <set>
- #include <climits>
- #include <utility>
- #include <map>
- #include <algorithm>
- #define INF 987654321
- #define MOD 1000000007
- typedef long long ll;
- typedef unsigned long long ull;
- inline int max( int x, int y ){ return x > y ? x : y ; }
- inline int min( int x, int y ){ return x < y ? x : y ; }
- inline ll max( ll x, ll y ){ return x > y ? x : y ; }
- inline ll min( ll x, ll y ){ return x < y ? x : y ; }
- inline ull max( ull x, ull y ){ return x > y ? x : y ; }
- inline ull min( ull x, ull y ){ return x < y ? x : y ; }
- int main(){
- int TC, N, eat;
- int ans = 0;
- scanf("%d", &TC);
- while( TC-- ){
- scanf("%d", &N);
- vector<int> Micro(N);
- vector<int> Eat(N);
- ans = 0;
- for( int i=0; i<N; ++i ){
- scanf("%d", &Micro[i]);
- }
- for( int i=0; i<N; ++i ){
- scanf("%d", &Eat[i]);
- }
- vector<pair<int, int> >order;
- for( int i=0; i<N; ++i ){
- order.push_back(make_pair( -Eat[i], i ));
- }
- sort(order.begin(), order.end());
- eat = 0;
- ans = 0;
- for( int i=0; i<N; ++i ){
- eat += Micro[order[i].second];
- ans = max( ans, eat+Eat[order[i].second] );
- }
- printf("%d\n", ans);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement