Wrong Answer
Code
#include<stdio.h>
int main()
{
int t;
scanf("%d", &t);
while (t--) {
int n;
scanf("%d", &n);
int pos = 0, neg = 0, zero = 0;
for (int i = 0; i < n; i++) {
int ele;
scanf("%d", &ele);
if (ele == 1) {
pos++;
} else if (ele == -1) {
neg++;
} else if (ele == 0) {
zero++;
}
}
int score = 0;
score += pos / 3;
pos %= 3;
while (pos > 0 && neg >= 2) {
score++;
pos--;
neg -= 2;
}
score += neg / 3;
neg %= 3;
if ((pos > 0) || (neg > 0 && neg != 3)) {
printf("0\n");
} else {
printf("%d\n", score);
}
}
return 0;
}
Information
- Submit By
- Type
- Submission
- Problem
- P1152 Special Array
- Contest
- Happy New Year 2025
- Language
- C++17 (G++ 13.2.0)
- Submit At
- 2025-01-02 16:19:10
- Judged At
- 2025-01-02 16:19:10
- Judged By
- Score
- 0
- Total Time
- 11ms
- Peak Memory
- 284.0 KiB