CSES - Datatähti 2015 loppu - Results
Submission details
Task:Omenat
Sender:laituli
Submission time:2015-01-29 12:30:54 +0200
Language:C++
Status:COMPILE ERROR

Compiler report

input/code.cpp: In function 'int main()':
input/code.cpp:20:9: error: 'i' was not declared in this scope
    if(a[i]==0||a[2]==0){
         ^

Code

#include<bits/stdc++.h>
using namespace std;
int main(){
	cin.sync_with_stdio(false);
	int n,a[3]={0,0,0},p;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>p;
		a[p%3]++;
	}
	p=abs(a[1]%3-a[2]%3);
	switch(p){
		case 0:
			cout<<n<<"\n";
			break;
		case 1:
			cout<<(n-1)<<"\n";
			break;
		case 2:
			if(a[i]==0||a[2]==0){
				cout<<(n-2)<<"\n";
			}
			cout<<(n-1)<<"\n";
			break;
	}
	return 0;
}