Code Submission Evaluation System Login

Datatähti 2015 loppu

Start:2015-01-29 12:15:00
End:2015-01-29 17:15:00
 

Tasks | Scoreboard | Statistics


CSES - Datatähti 2015 loppu - Results
History
2015-01-29 12:38:17100
2015-01-29 12:32:160
2015-01-29 12:30:54
Task:Omenat
Sender:laituli
Submission time:2015-01-29 12:30:54
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;
}