CSES - Datatähti 2017 alku - Results
Submission details
Task:Kolikot
Sender:miksu.r
Submission time:2016-10-15 00:41:39 +0300
Language:C++
Status:COMPILE ERROR

Compiler report

input/code.cpp: In function 'int main()':
input/code.cpp:56:3: error: 'timer' was not declared in this scope
   timer = perms.size();
   ^

Code

#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <math.h>
#include <algorithm>
using namespace std;
unsigned long n;
string inf;
string ins;
string tmp;
unsigned long index;
vector<unsigned long> perms;
int main(){
getline(cin, inf);
n = stoul(inf);
unsigned long x[n];
getline(cin, ins);
stringstream t(ins);
index = 0;
while(t >> tmp){
x[index] = stoul(tmp);
index++;
}
if(n == 1){
cout << x[0];
return 0;
}
sort(x, x + n);
perms.push_back(x[0]);
perms.push_back(x[1]);
perms.push_back(x[1]+x[0]);
index = 0;
for(short i = 0; i < 3; i++){
if(perms[i] == index + 1){
index++;
}
}
for(unsigned long i = 2; i < n; i++){
perms.push_back(x[i]);
if(perms[perms.size() - 1] == index + 1){
index++;
}
timer = perms.size();
for(unsigned long j = 0; j < timer - 1; j++){
perms.push_back(perms[j] + x[i]);
if(perms[perms.size() - 1] == index + 1){
index++;
}
}
if(i > index){
break;
}
}
cout << index << endl;
return 0;
}