QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#567320 | #9313. Make Max | Xinkie_L | WA | 0ms | 1624kb | C++14 | 1.1kb | 2024-09-16 11:06:03 | 2024-09-16 11:06:03 |
Judging History
answer
#include <stdio.h>
int main() {
int t;
scanf("%d", &t); // 读取测试用例的数量
while (t--) {
int n;
scanf("%d", &n); // 读取序列的长度
int a[n];
for (int i = 0; i < n; i++) {
scanf("%d", &a[i]); // 读取序列中的每个元素
}
int operations = 0;
int i = 0;
while (i < n) {
// 找到连续相同元素的起始位置
while (i + 1 < n && a[i] == a[i + 1]) {
i++;
}
int start = i;
// 找到连续相同元素的结束位置
while (i + 1 < n && a[i] != a[i + 1]) {
i++;
}
int end = i;
// 如果end等于start,说明整个序列都是相同的元素,不能进行操作
if (start != end) {
operations++;
}
// 跳过已经处理的连续相同元素的段
i++;
}
printf("%d\n", operations);
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 1624kb
input:
4 2 1 2 2 2 2 7 1 1 1 2 2 2 2 3 1 2 3
output:
1 0 1 1
result:
wrong answer 3rd numbers differ - expected: '3', found: '1'