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;
for (int i = 0; i < n; i++) {
int ele;
scanf("%d", &ele);
if (ele == 1) pos++;
else if (ele == -1) neg++;
}
int sum1 = pos / 3;
pos %= 3;
int sub = 0;
while (pos > 0 && neg >= 2) {
sub++;
pos--;
neg -= 2;
}
sub += neg / 3;
printf("%d\n", sum1 + sub);
}
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 15:31:47
- Judged At
- 2025-01-02 15:31:47
- Judged By
- Score
- 0
- Total Time
- 13ms
- Peak Memory
- 540.0 KiB