Submission #3199101


Source Code Expand

Copy
#include "bits/stdc++.h"

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n, x;
	cin >> n >> x;
	vl v(n);
	REP(i, n)cin >> v[i];
	sort(ALL(v));
	REP(i, n-1) {
		if (x < v[i]) {
			cout << i << endl;
			return 0;
		}
		x -= v[i];
	}
	if (x == v.back()) {
		cout << n << endl;
	}
	else {
		cout << n - 1 << endl;
	}
}

Submission Info

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

Compile Error

./Main.cpp:1:10: fatal error: 'bits/stdc++.h' file not found
#include "bits/stdc++.h"
         ^
1 error generated.