Submission #3199781


Source Code Expand

Copy
import std.stdio;
import std.algorithm;
import std.conv;
import std.math;
import std.string;

void main()
{
	auto tokens = split(chomp(readln()));
	auto n = to!int(tokens[0]);
	auto x = to!int(tokens[1]);
	int[] a;
	foreach (token; split(chomp(readln())))
	{
		a ~= to!int(token);
	}
	a.sort;
	
	int result;
	foreach (i, e; a)
	{
		if (e <= x)
		{
			x -= e;
		}
		else
		{
			result = i;
		}
	}

	writeln(result);
	stdout.flush();
}

Submission Info

Submission Time
Task A - Candy Distribution Again
User daut
Language D (GDC 4.9.4)
Score 0
Code Size 466 Byte
Status

Compile Error

./Main.d:28: error: cannot implicitly convert expression (i) of type ulong to int