CSES - Datatähti 2017 alku - Results
Submission details
Task:Kolikot
Sender:kapesu8
Submission time:2016-10-06 14:44:15 +0300
Language:C++
Status:COMPILE ERROR

Compiler report

input/code.cpp: In function 'int main()':
input/code.cpp:15:33: error: 'memset' was not declared in this scope
  memset(coins,0,sizeof(int)*1001);
                                 ^

Code

#include <iostream>
#include <string>
#include <math.h>



int main()
{
	int result = 0;
	int count;
	std::cin >> count;
	if(count > 1000)
		return 0;
	int *coins = new int[1001];
	memset(coins,0,sizeof(int)*1001);
	for(int i = 0;i < count;i++)
	{
		int this_number;
		std::cin >> this_number;
		coins[this_number]++;
	}
	result += coins[1];
	for(int i = 2;i < count;i++)
	{
		if(coins[i-1] >= i-1)
			result+= coins[i] * i;
	}
	std::cout << result + 1;

	return 0;
}