Problem:
B : RUPC
問題文
ロシア連邦でプログラミングコンテストが開催される。コンテストには
N
個の問題が出題され、
M
人の参加者がいる。問題
i
には得点
a_i
が設定されており、参加者
j
の実力は
b_j
であることがわかっている。問題
i
と参加者
j
について、
a_i ≤ b_j
のときかつそのとき限り、参加者
j
は問題
i
を必ず解くことができる。 コンテストを通した参加者の得点は、その人が解くことができた問題の得点の総和である。また、参加者
j
は、このコンテストでの目標点数
c_j
を定めている。
各参加者が、目標点数以上の得点を獲得できるか判定せよ。
入力
入力は以下の形式で与えられる。
N
a_{0}
a_{1}
a_{2}
…
a_{N−1}
M
b_{0}
b_{1}
b_{2}
…
b_{M−1}
c_{0}
c_{1}
c_{2}
…
c_{M−1}
制約
入力はすべて整数である
1 \≤ N \≤ 300\,000
1 \≤ M \≤ 300\,000
0 \≤ a_{i} \≤ 1\,000\,000
0 \≤ b_{i} \≤ 1\,000\,000
0 \≤ c_{i} \≤ ∑a_k
出力
答えを
M
行で出力せよ。
i
行目には、参加者
i−1
が目標点数以上の得点を獲得できるなら
Yes
、できないなら
No
と出力せよ。
サンプル
サンプル入力1
6
1 2 1 3 4 5
7
1 3 4 5 3 1 0
2 4 5 3 4 5 3
サンプル出力1
Yes
Yes
Yes
Yes
Yes
No
No
各参加者の得られる得点は以下のようになる。
参加者0 :
1+1=2
参加者1 :
1+2+1+3=7
参加者2 :
1+2+1+3+4=11
参加者3 :
1+2+1+3+4+5=16
参加者4 :
1+2+1+3=7
参加者5 :
1+1=2
参加者6 :
0
サンプル入力2
8
1 1 2 3 3 4 6 100
4
1 3 4 99
1 10 15 120
サンプル出力2
Yes
Yes
No
No

Submitted solutions:

code_snippet: #include <bits/stdc++.h>
using namespace std;
#define ll long long
#define all(x) (x).begin(), (x).end()
int a[300001], b1[300001];
ll c1[300001];
ll pr[300001];

int main() {
    int n;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    sort(a, a + n);
    pr[0] = a[0];
    for (int i = 1; i < n; i++) {
        pr[i] = pr[i - 1] + a[i];
    }
    int m;
    cin >> m;
    for (int i = 0; i < m; i++) {
        cin >> b1[i];
    }
    for (int i = 0; i < m; i++) {
        cin >> c1[i];
    }
    for (int i = 0; i < m; i++) {
        int b = b1[i];
        ll c = c1[i];
        
        int ind = upper_bound(a, a + n, b) - a - 1;
        ll poss = 0;
        if (ind != -1) {
            poss = pr[ind];
        }
        if (poss >= c) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    }
}
accuracy: 1
time_ms: 520
memory_kb: 10016
final_rank: 6

code_snippet: #include <bits/stdc++.h>
using namespace std;
#define ll long long
#define all(x) (x).begin(), (x).end()
int a[300001], b1[300001], c1[300001];
ll pr[300001];

int main() {
    int n;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    sort(a, a + n);
    pr[0] = a[0];
    for (int i = 1; i < n; i++) {
        pr[i] = pr[i - 1] + a[i];
    }
    int m;
    cin >> m;
    for (int i = 0; i < m; i++) {
        cin >> b1[i];
    }
    for (int i = 0; i < m; i++) {
        cin >> c1[i];
    }
    for (int i = 0; i < m; i++) {
        int b = b1[i];
        int c = c1[i];
        
        int ind = upper_bound(a, a + n, b) - a - 1;
        int poss = 0;
        if (ind != -1) {
            poss = pr[ind];
        }
        if (poss >= c) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    }
}
accuracy: 0.7058823529411765
time_ms: 360
memory_kb: 6624
final_rank: 13

code_snippet: #include <bits/stdc++.h>
using namespace std;
#define ll long long
#define all(x) (x).begin(), (x).end()
int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    for (int& i : a) cin >> i;
    int m;
    cin >> m;
    vector<int> b(m);
    vector<ll> c(m);
    for (int& i : b) cin >> i;
    for (ll& i : c) cin >> i;
    vector< vector<ll> > u;
    for (size_t i = 0; i < m; i++) {
        vector<ll> t(3);
        t[0] = b[i];
        t[1] = c[i];
        t[2] = i;
        u.push_back(t);
    }
    sort(all(u));
    sort(all(a));
    int ptr = 0;
    ll ans = 0;
    vector<bool> fin(m);
    for (vector<ll>& i : u) {
        while (ptr < n && a[ptr] <= i[0]) {
            ans += a[ptr];
            ptr++;
        }
        if (ans >= i[1]) {
            fin[i[2]] = true;
        }
    }
    for (bool i : fin) {
        if (!i) {
            cout << "No\n";
        } else {
            cout << "Yes\n";
        }
    }
}
accuracy: 1
time_ms: 240
memory_kb: 29540
final_rank: 7

code_snippet: #include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
#define all(x) (x).begin(), (x).end()
int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    for (int& i : a) cin >> i;
    int m;
    cin >> m;
    vector<int> b(m);
    vector<int> c(m);
    for (int& i : b) cin >> i;
    for (int& i : c) cin >> i;
    vector< vector<int> > u;
    for (int i = 0; i < m; i++) {
        vector<int> t(3);
        t[0] = b[i];
        t[1] = c[i];
        t[2] = i;
        u.push_back(t);
    }
    sort(all(u));
    sort(all(a));
    int ptr = 0;
    int ans = 0;
    vector<bool> fin(m);
    for (vector<int>& i : u) {
        while (ptr < n && a[ptr] <= i[0]) {
            ans += a[ptr];
            ptr++;
        }
        if (ans >= i[1]) {
            fin[i[2]] = true;
        }
    }
    for (bool i : fin) {
        if (!i) {
            cout << "No\n";
        } else {
            cout << "Yes\n";
        }
    }
}
accuracy: 0.7058823529411765
time_ms: 120
memory_kb: 27880
final_rank: 16

code_snippet: #include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, s, t) for (ll i = s; i < (ll)(t); i++)
#define rrep(i, s, t) for(ll i = (ll)(t) - 1; i >= (ll)(s); i--)
#define all(x) begin(x), end(x)
#define TT template<typename T>
TT using vec = vector<T>;
TT using minheap = priority_queue<T, vector<T>, greater<T>>;
TT using maxheap = priority_queue<T>;

struct io_setup {
    io_setup() {
        ios::sync_with_stdio(false);
        std::cin.tie(nullptr);
        cout << fixed << setprecision(15);
    }
} io_setup;

TT bool chmin(T &x, T y) { return x > y ? (x = y, true) : false; }
TT bool chmax(T &x, T y) { return x < y ? (x = y, true) : false; }

const int inf = 1001001001;
const ll INF = 2002002002002002002;

int main(){
	int n;
	cin>>n;
	vector<ll> a(n);
	rep(i,0,n) cin>>a.at(i);
	sort(a.begin(),a.end());
	int m;
	cin>>m;
	vector<ll> b(m),c(m);
	rep(i,0,m) cin>>b.at(i);
	rep(i,0,m) cin>>c.at(i);
	vector<ll> sa(n+1);
	rep(i,0,n) sa.at(i+1)=sa.at(i)+a.at(i);
	rep(i,0,m){
		auto itr=upper_bound(a.begin(),a.end(),b.at(i))-a.begin();
		if(sa.at(itr)>=c.at(i)) cout<<"Yes\n";
		else cout<<"No\n";
	}
}
accuracy: 1
time_ms: 100
memory_kb: 12112
final_rank: 1

code_snippet: #include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,a,b) for(ll i = a; i < b; i++)
#define all(a) (a).begin(), (a).end()

int main(){
    int n;
    cin >> n;
    vector<ll>a(n+1,0);
    rep(i,1,n+1) cin >> a[i];
    sort(all(a));
    vector<ll>sm(all(a));
    rep(i,1,n+1) sm[i] += sm[i-1];

    int m;
    cin >> m;
    vector<ll>b(m),c(m);
    rep(i,0,m) cin >> b[i];
    rep(i,0,m) cin >> c[i];

    rep(i,0,m){
        auto itr = upper_bound(all(a), b[i]);
        itr--;
        if(sm[itr-a.begin()] >= c[i]) cout << "Yes" << endl;
        else cout <<"No" << endl;
    }
}
accuracy: 1
time_ms: 420
memory_kb: 12352
final_rank: 4

code_snippet: #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define reps(i, l, r) for(ll i = (l); i < (r); i++)
#define endl "\n";
const ll INF = 1e16;
const ll mod1 = 1000000007;
const ll mod2 = 998244353;
int dx[4] = {-1, 0, 1, 0};
int dy[4] = {0, -1, 0, 1};
void solve() {
	ll N; cin >> N;
	vector<ll>A(N);
	vector<ll>sumA(N + 1);
	rep(i, N) {cin >> A[i];}
	ll M; cin >> M;
	vector<ll>B(M), C(M);
	rep(i, M) cin >> B[i];
	rep(i, M) cin >> C[i];
	sort(A.begin(), A.end());
	rep(i, N) sumA[i + 1] = A[i];
	reps(i, 1, N + 1) sumA[i] += sumA[i - 1];
	rep(i, M) {
		ll it = upper_bound(A.begin(), A.end(), B[i]) - A.begin();
		if (sumA[it] >= C[i]) {cout << "Yes" << endl;}
		else {cout << "No" << endl;}
	}
}
int main() {
	int T = 1;
	//cin >> T;
	while (T--) solve();
}
accuracy: 1
time_ms: 230
memory_kb: 12140
final_rank: 2

code_snippet: #include <bits/stdc++.h>
using namespace std;
int main () {
   int N, M;
   long S = 0;
   cin >> N;
   vector<int> a(N);
   for (int i=0; i < N; i++) {
    cin >> a[i];
    S += a[i];
   }
   sort(a.begin(), a.end());
   reverse(a.begin(), a.end());
   cin >> M;
   vector<int> b(M), c(M);
   for (int i=0; i < M; i++) {
    cin >> b[i];
   }
   for (int i=0; i < M; i++) {
    cin >> c[i];
   }
   for (int j=0; j < M; j++) {
    long sum = 0;
    if (S <= c[j]) {
        cout << "No" << '\n';
        break;
    }
    for (int i=0; i < N; i++) {
    if (b[j] >= a[i]) {
        break;
    }else {
        sum += a[i];
    }
   }
   if ((S - sum) >= c[j]) {
    cout << "Yes" << '\n';
   }else {
    cout << "No" << '\n';
   }
   }
}
accuracy: 0.11764705882352941
time_ms: 70
memory_kb: 4264
final_rank: 17

code_snippet: #include <bits/stdc++.h>
using namespace std;
int main () {
   int N, M;
   long S=0;
   cin >> N;
   vector<int> a(N);
   for (int i=0; i < N; i++) {
    cin >> a[i];
    S += a[i];
   }
   sort(a.begin(), a.end());
   reverse(a.begin(), a.end());
   cin >> M;
   vector<int> b(M), c(M);
   for (int i=0; i < M; i++) {
    cin >> b[i];
   }
   for (int i=0; i < M; i++) {
    cin >> c[i];
   }
   for (int j=0; j < M; j++) {
    long sum = 0;
    if (S <= c[j]) {
        cout << "No" << '\n';
        break;
    }
    for (int i=0; i < N; i++) {
    if (b[j] >= a[i]) {
        break;
    }else {
        sum += a[i];
    }
   }
   if ((S - sum) >= c[j]) {
    cout << "Yes" << '\n';
   }else {
    cout << "No" << '\n';
   }
   }
}
accuracy: 0.11764705882352941
time_ms: 70
memory_kb: 4388
final_rank: 18

code_snippet: #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, a, b) for (int i = (a); i < (b); i++)

int main() {
    int n, m;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    cin >> m;
    vector<int> b(m), c(m);
    rep(i, m) cin >> b[i];
    rep(i, m) cin >> c[i];
    sort(a.begin(), a.end());
    vector<int> sum(n);
    vector<bool> ans(m, false);
    sum[0] = a[0];
    reps(i, 1, n) sum[i] += sum[i - 1] + a[i];
    int left = 0;
    int right = n - 1;
    rep(i, m) {
        if(c[i] == 0)ans[i] = true;
        left = 0;
        right = n - 1;
        while (right >= left) {
            int mid = left + (right - left) / 2;
            if (a[mid] == b[i]) {
                while (mid < n - 1 && a[mid + 1] == b[i]) {
                    mid++;
                }
                if (sum[mid] >= c[i])
                    ans[i] = true;
                break;
            } else if (a[mid] < b[i]) {
                left = mid + 1;

            } else if (a[mid] > b[i]) {
                right = mid - 1;
            } else if (mid == n - 1 || a[mid] < b[i] && a[mid + 1] > b[i]) {
                if (sum[mid] >= c[i])
                    ans[i] = true;
                break;
            }
        }
    }
    rep(i, m) {
        if (ans[i])
            cout << "Yes" << endl;
        else
            cout << "No" << endl;
    }
}
accuracy: 0.11764705882352941
time_ms: 210
memory_kb: 5056
final_rank: 19

code_snippet: #include<bits/stdc++.h>

using namespace std;

int upper_bound(const vector<int>& a, int val){
    int l = 0, r = a.size();
    while(l < r){
        int mid = (l + r) / 2;
        if(a[mid] > val) r = mid;
        else l = mid + 1; 
    }
    return l;
}
int main(){
    int n, m; cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++) cin >> a[i];
    cin >> m;
    vector<int> b(m), c(m);
    for(int i = 0; i < m; i++) cin >> b[i];
    for(int i = 0; i < m; i++) cin >> c[i];
    sort(a.begin(), a.end());
    vector<long long> pre_s(n + 1, 0);
    for(int i = 0; i < n; i++){
        pre_s[i + 1] = pre_s[i] + a[i];
    }
    for(int i = 0; i < m; i++){
        int nums = upper_bound(a, b[i]);
        if(pre_s[nums] >= c[i]){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
    }
    return 0;
}
accuracy: 0.7058823529411765
time_ms: 350
memory_kb: 6208
final_rank: 12

code_snippet: #include <bits/stdc++.h>

using namespace std;


int main() {
    long long n, m;
    cin >> n;
    long long a[n];
    for(long long i = 0; i < n; i++) cin >> a[i];
    cin >> m;
    long long b[m];
    long long c[m];
    for(long long i = 0; i < m; i++) cin >> b[i];
    for(long long i = 0; i < m; i++) cin >> c[i];

    sort(a, a + n);
    long long toku[1000011] = {};
    toku[0] = 0;
    long long toketa = 0;
    for (long long i = 1; i < 1000011; i++) {
        toku[i] = toku[i - 1];
        while(i >= a[toketa] && toketa < n){
            toku[i] += a[toketa];
            toketa++;
        }
    }

    for (long long i = 0; i < m; i++) {
        cout << (toku[b[i]] >= c[i] ? "Yes" : "No") << endl;
    }
    return 0;
}
accuracy: 1
time_ms: 490
memory_kb: 17924
final_rank: 8

code_snippet: #include <bits/stdc++.h>
#include <vector>
using namespace std;
using ll=long long;
using pint=pair<int,int>;
using pll=pair<ll,ll>;
using pque_int=priority_queue<int>;
using vint=vector<int>;
using vll=vector<ll>;
using vvint=vector<vector<int>>;
using vvll=vector<vector<ll>>;
int inf=2'000'000'000;
ll infll=1'000'000'000'000'000'000ll;
#define rep(i,n) for (int i=0; i < (int) n; i++)
#define rep1(i,n) for (int i=1; i < (int) n; i++)
int binary_search(ll key, vll &vec) {
    int left=-1;
    int right=vec.size();
    while (right-left>1) {
        int mid=left+(right-left)/2;
        if (vec[mid]>key) right=mid;
        else left=mid;
    }
    return left;
}
int main() {
    int N;
    cin >> N;
    vll a(N);
    rep(i,N) {
        cin >> a[i];
    }
    sort(a.begin(),a.end());
    vll asum(N,0);
    rep(i,N) {
        if (i==0) asum[0]=a[0];
        else asum[i]=a[i]+asum[i-1];
    }
    int M;
    cin >> M;
    vll b(M),c(M);
    rep(i,M) {
        cin >> b[i];
    }
    rep(i,M) {
        cin >> c[i];
    }
    rep(i,M) {
        int s=binary_search(b[i],a);
        if (s==-1) {
            if (c[i]==0) cout << "Yes" << endl;
            else cout << "No" << endl;
        } else if (asum[s]>=c[i]) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    }
}
accuracy: 1
time_ms: 420
memory_kb: 12168
final_rank: 3

code_snippet: #include <iostream>
#include <vector>
using namespace std;



int main(){
 int N;
 cin >>N;
 vector<int> problem(N);
 for(int i=0;i<N;i++){
   cin >> problem[i];
  }
  int M;
  cin >> M;
  vector<int> sankasya(M);
  vector<int> mokuhyou(M);
  for(int j=0;j<M;j++){
    cin >> sankasya[j];
  }
  for(int j=0;j<M;j++){
    cin >> mokuhyou[j];
  }
  for(int k=0;k<M;k++){
    int tokuten=0;
    for(int m=0;m<N;m++){
      if(sankasya[k]>=problem[m]){
        tokuten=tokuten+problem[m];
      }
      if(tokuten>=mokuhyou[k]){
      cout << "Yes"<<endl;
      break;
      }
    }
    if(tokuten<mokuhyou[k]){
      cout << "No"<< endl;
    }
  }
}
accuracy: 0.7058823529411765
time_ms: 330
memory_kb: 5488
final_rank: 11

code_snippet: #include <bits/stdc++.h>

using namespace std;


int main() {
    int n, m;
    cin >> n;
    int a[n];
    for(int i = 0; i < n; i++) cin >> a[i];
    cin >> m;
    int b[m];
    int c[m];
    for(int i = 0; i < m; i++) cin >> b[i];
    for(int i = 0; i < m; i++) cin >> c[i];

    sort(a, a + n);
    int toku[1000011] = {};
    toku[0] = 0;
    int toketa = 0;
    for (int i = 1; i < 1000011; i++) {
        toku[i] = toku[i - 1];
        while(i >= a[toketa] && toketa < n){
            toku[i] += a[toketa];
            toketa++;
        }
    }

    for (int i = 0; i < m; i++) {
        cout << (toku[b[i]] >= c[i] ? "Yes" : "No") << endl;
    }
    return 0;
}
accuracy: 0.7058823529411765
time_ms: 340
memory_kb: 9208
final_rank: 15

code_snippet: #include <bits/stdc++.h>
#include <vector>
using namespace std;
using ll=long long;
using pint=pair<int,int>;
using pll=pair<ll,ll>;
using pque_int=priority_queue<int>;
using vint=vector<int>;
using vll=vector<ll>;
using vvint=vector<vector<int>>;
using vvll=vector<vector<ll>>;
int inf=2'000'000'000;
ll infll=1'000'000'000'000'000'000ll;
#define rep(i,n) for (int i=0; i < (int) n; i++)
#define rep1(i,n) for (int i=1; i < (int) n; i++)
int binary_search(int key, vint &vec) {
    int left=-1;
    int right=vec.size();
    while (right-left>1) {
        int mid=left+(right-left)/2;
        if (vec[mid]>key) right=mid;
        else left=mid;
    }
    return left;
}
int main() {
    int N;
    cin >> N;
    vint a(N);
    rep(i,N) {
        cin >> a[i];
    }
    sort(a.begin(),a.end());
    vint asum(N,0);
    asum[0]=a[0];
    rep(i,N) {
        if (i==0) continue;
        asum[i]=a[i]+asum[i-1];
    }
    int M;
    cin >> M;
    vint b(M),c(M);
    rep(i,M) {
        cin >> b[i];
    }
    rep(i,M) {
        cin >> c[i];
    }
    rep(i,M) {
        int s=binary_search(b[i],a);
        if (asum[s]>=c[i]) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    }
}
accuracy: 0.7058823529411765
time_ms: 280
memory_kb: 6016
final_rank: 10

code_snippet: #include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,a,b) for(ll i=(a);i<(b);i++)

int main() {
    ll n;cin >> n;
    vector<ll> a(n),A(n);
    for(ll i=0;i<n;i++){
        cin >> a[i];
    }
    sort(a.begin(),a.end());
    A[0]=a[0];
    for(ll i=1;i<n;i++){
        A[i]=A[i-1]+a[i];
    }
    ll m; cin >> m;
    vector<ll> b(m),c(m),d(m);
    vector<string> ans(m,"No");
    for(ll i=0;i<m;i++){
        cin >> b[i];
    }
    for(ll i=0;i<m;i++){
        cin >> c[i];
    }
    for(ll i=0;i<m;i++){
        if(b[i]<a[0]){
            d[i]=-1;
        
        }else if(a[0]<=b[i] && b[i]<a[n-1]){
            ll ok=0,ng=n-1;
            while(abs(ok-ng)>1){
                int mid = int((ok+ng)/2);
                if(b[i]>=a[mid]){
                    ok=mid;
                }else{
                    ng=mid;
                }
            }
            d[i]=ok;
        }else{
            d[i]=n-1;
        }
        if(d[i]==-1){
            if(c[i]<=0){
                ans[i]="Yes";
            }
        }else if(A[d[i]]>=c[i]){
            ans[i]="Yes";
        }
    }
    for(ll i=0;i<m;i++){
        cout << ans[i] << "\n";
    }
}
accuracy: 1
time_ms: 230
memory_kb: 23980
final_rank: 5

code_snippet: #include <bits/stdc++.h>
using namespace std;
int main () {
   int N, M, S;
   cin >> N;
   vector<int> a(N);
   for (int i=0; i < N; i++) {
    cin >> a[i];
    S += a[i];
   }
   sort(a.begin(), a.end());
   cin >> M;
   vector<int> b(M), c(M);
   for (int i=0; i < M; i++) {
    cin >> b[i];
   }
   for (int i=0; i < M; i++) {
    cin >> c[i];
   }
   for (int j=0; j < M; j++) {
    int sum=0;
    if (S <= c[j]) {
        cout << "No" << '\n';
        break;
    }
    for (int i=0; i < N; i++) {
    if (b[j] >= a[i]) {
        sum += a[i];
    }
   }
   if (sum >= c[j]) {
    cout << "Yes" << '\n';
   }else {
    cout << "No" << '\n';
   }
   }
}
accuracy: 0.7058823529411765
time_ms: 80
memory_kb: 5432
final_rank: 9

code_snippet: #include <bits/stdc++.h>
using namespace std;
int main () {
   int N, M, S;
   cin >> N;
   vector<int> a(N);
   for (int i=0; i < N; i++) {
    cin >> a[i];
    S += a[i];
   }
   sort(a.begin(), a.end());
   cin >> M;
   vector<int> b(M), c(M);
   for (int i=0; i < M; i++) {
    cin >> b[i];
   }
   for (int i=0; i < M; i++) {
    cin >> c[i];
   }
   for (int j=0; j < M; j++) {
    int sum=0;
    if (S <= c[j]) {
        break;
    }
    for (int i=0; i < N; i++) {
    if (b[j] >= a[i]) {
        sum += a[i];
    }
   }
   if (sum >= c[j]) {
    cout << "Yes" << '\n';
   }else {
    cout << "No" << '\n';
   }
   }




}
accuracy: 0.08823529411764706
time_ms: 70
memory_kb: 3800
final_rank: 20

code_snippet: #include <bits/stdc++.h>

using namespace std;


int main() {
    int n, m;
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++) cin >> a[i];
    cin >> m;
    vector<int> b(m);
    for(int i = 0; i < m; i++) cin >> b[i];
    vector<int> c(m);
    for(int i = 0; i < m; i++) cin >> c[i];

    sort(a.begin(), a.end());
    int toku[1000011] = {};
    toku[0] = 0;
    int toketa = 0;
    for (int i = 1; i < 1000011; i++) {
        toku[i] = toku[i - 1];
        while(i >= a[toketa] && toketa < n){
            toku[i] += a[toketa];
            toketa++;
        }
    }

    for (int i = 0; i < m; i++) {
        cout << (toku[b[i]] >= c[i] ? "Yes" : "No") << endl;
    }
    return 0;
}
accuracy: 0.7058823529411765
time_ms: 330
memory_kb: 9388
final_rank: 14