Submission #3222749


Source Code Expand

Copy
#include <bits/stdc++.h>

using namespace std;

#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define ll long long int
#define f(i,a,b) for(ll i=a;i<b;i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define en '\n'
int main()
{
IOS;
int t=1;
//cin>>t;
while(t--)
{
ll n,x;
  cin>>n>>x;
  ll a[n];
  f(i,0,n)
    cin>>a[i];
  sort(a,a+n);
  f(i,1,n)
    a[i]+=a[i-1];
  ll p=lower_bound(a,a+n,x)-a;
  if(p>=n)
    cout<<n-1;
  else if(a[p]>x)
    cout<<p;
  else if(a[p]==x)
    cout<<p+1;
}
}

Submission Info

Submission Time
Task A - Candy Distribution Again
User aj_akansh
Language C++14 (GCC 5.4.1)
Score 200
Code Size 617 Byte
Status
Exec Time 1 ms
Memory 256 KB

Test Cases

Set Name Score / Max Score Test Cases
Sample 0 / 0 0_00.txt, 0_01.txt, 0_02.txt, 0_03.txt
All 200 / 200 0_00.txt, 0_01.txt, 0_02.txt, 0_03.txt, 1_00.txt, 1_01.txt, 1_02.txt, 1_03.txt, 1_04.txt, 1_05.txt, 1_06.txt, 1_07.txt
Case Name Status Exec Time Memory
0_00.txt 1 ms 256 KB
0_01.txt 1 ms 256 KB
0_02.txt 1 ms 256 KB
0_03.txt 1 ms 256 KB
1_00.txt 1 ms 256 KB
1_01.txt 1 ms 256 KB
1_02.txt 1 ms 256 KB
1_03.txt 1 ms 256 KB
1_04.txt 1 ms 256 KB
1_05.txt 1 ms 256 KB
1_06.txt 1 ms 256 KB
1_07.txt 1 ms 256 KB