Submission #3199785


Source Code Expand

Copy
/*
    Rem is cute :D
*/

# include <bits/stdc++.h>

using namespace std;

#define pii pair<int, int>
#define pll pair<ll, ll>

#define pb push_back
#define eb emplace_back
#define mp make_pair

#define fi first
#define se second

#define y0 asjdlksajldjals
#define y1 ajsldjalksdkjlk

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

const int inf = (int)1e9 + 7;
const int maxn = (int)4e5 + 7;
const int lmaxn = (int)6e5 + 7;
const ll linf = (ll)1e18 + 7;

const ld eps = ld(1e-11);

const ll dx[] = {-1, 0, 0, 1};
const ll dy[] = {0, -1, 1, 0};

ll gcd(ll a, ll b){
    while(b) a %= b, swap(a, b);
    return a | b;
}

ll lcm(ll a, ll b){
    return a * b / gcd(a, b);
}

ll k, a[maxn], n, m;
string s;

int main(){
  cin >> n >> m;
  for(int i = 1; i <= n; i++)
    cin >> a[i];
  sort(a + 1, a + 1 + n);
  for(int i = 1; i <= n; i++){
    if(m - a[i] >= 0){
      m -= a[i];
    }
    else{
      cout << i - 1;
      return 0;
    }
  }
  cout << n;
  return 0;
}

Submission Info

Submission Time
Task A - Candy Distribution Again
User Trood
Language C++14 (Clang 3.8.0)
Score 0
Code Size 1067 Byte
Status

Compile Error

./Main.cpp:5:11: fatal error: 'bits/stdc++.h' file not found
# include <bits/stdc++.h>
          ^
1 error generated.