#include using namespace std; using namespace std::chrono; using ll = long long; using ull = unsigned long long; using vi = vector; using vl = vector; using vs = vector; using vii = vector>; using vll = vector>; #define ALL(x) (x).begin(), (x).end() #define coutY cout << "Yes" << endl; #define coutN cout << "No" << endl; #define arrIn(arr, start, N) for (ll i = (start); i < (N); ++i) cin >> arr[i]; #define arrOut(arr, start, N) for (ll i = (start); i < (N); ++i) { cout << arr[i] <<" "; } cout << endl; #define mod9 998244353 #define mod1 1000000007 void yn(bool tf) { cout << (tf ? "Yes\n" : "No\n"); } void YN(bool tf) { cout << (tf ? "YES\n" : "NO\n"); } string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ"; string abc="abcdefghijklmnopqrstuvwxyz"; //cout << fixed << setprecision(20) << bool kaibun(string S){ string T=S; reverse(ALL(S)); return S==T; } auto start = high_resolution_clock::now(); bool CheckTime(auto limit,auto eps){ auto end = high_resolution_clock::now(); return duration_cast(end - start).count()> T; for(ll t=0;t> N; vector> A(N+1,make_pair(0,0)); vl B(N+1,0); for(ll i=1;i<=N;i++){ cin >> A[i].first; A[i].second=i; } arrIn(B,1,N+1); sort(ALL(A)); vl ruiseki(N+1,0); ll max=0; ll index=0; for(ll i=1;i<=N;i++){ ruiseki[i]=ruiseki[i-1]+A[i].first; B[i]+=B[i-1]; if(max