Algorithm
Code Examples
#1 Code Example with C++ Programming
Code -
C++ Programming
#include <cstdio>
int main(){
long n; scanf("%ld\n", &n);
long zeros(0), ones(0), twos(0);
while(n--){
long t; scanf("%ld", &t);
if(t % 3 == 0){++zeros;}
else if(t % 3 == 1){++ones;}
else if(t % 3 == 2){++twos;}
}
long total = (zeros / 2) + (ones < twos ? ones : twos);
printf("%ld\n", total>;
return 0;
}
Copy The Code &
Try With Live Editor
Input
3
123 123 99
123 123 99
Output
1
Demonstration
Codeforces Solution-C. Lucky Tickets-Solution in C, C++, Java, Python