Source Code
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int N = 100000+1;
int main() {
    ll n,x,t,rem,sum=0,ctr =0,curr=0;
    int v[N];
    cin>>n>>x>>t;
    for(ll i = 0 ; i < n ; i++){
        cin>>v[i];
        sum+=v[i];
    }
    sum+= x;
    rem = t%sum;
    if(rem >= t){
        cout<<1<<endl;
        return 0;
    }
    sort(v,v+n);
    if(x >= rem || rem+x >= sum){
        ctr++;
    }

    for(ll i = 0 ; i < n ; i++){
        curr+=v[i];
        if((curr < rem) && ((curr+x) >= rem)){
            ctr++;
        }
        else
            break;
    }
    cout<<ctr<<endl;
    return 0 ;
}
Copy
Treasure sarah_alsharif_
GNU G++17
1 ms
1.1 MB
Wrong Answer