Submission #3199706


Source Code Expand

Copy
//inlclude前用define 
#define _USE_MATH_DEFINES

//include
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<type_traits>
#include<numeric>
#include<limits>
using namespace std;
//typedef
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;

//grobal変数


int main() {
	int n, x;
	cin >> n >> x;
	VI a(n);
	for (int i = 0; i < n; i++) cin >> a[i];

	sort(a.begin(), a.end());
	int cnt = 0;
	for (int i = n - 1; i >= 0; i--) {
		if (x - a[i] >= 0) {
			if (i == 0 && a[i]==x) {
				cnt++;
				x -= a[i];
			}
			else if (i != 0) {
				cnt++;
				x -= a[i];
			}
		}
	}
	cout << cnt << endl;
	return 0;
}

Submission Info

Submission Time
Task A - Candy Distribution Again
User mickey_1024
Language C (GCC 5.4.1)
Score 0
Code Size 721 Byte
Status

Compile Error

./Main.c:5:19: fatal error: iostream: No such file or directory
 #include<iostream>
                   ^
compilation terminated.