QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#568924 | #9313. Make Max | yylx | WA | 0ms | 3572kb | C++14 | 1.2kb | 2024-09-16 19:17:40 | 2024-09-16 19:17:41 |
Judging History
answer
#include <iostream>
#include <vector>
using namespace std;
int main() {
int t;
cin >> t; // Number of test cases
while (t--) {
int n;
cin >> n; // Length of the array
vector<int> a(n);
for (int i = 0; i < n; ++i) {
cin >> a[i]; // Array elements
}
int operations = 0;
int last_pos = n - 1;
// Start from the last element and try to create the largest uniform subarray
while (last_pos > 0) {
int current = last_pos;
// Find the largest uniform subarray starting from the last element
while (current > 0 && a[current - 1] == a[last_pos]) {
current--;
}
// If the current subarray isn't the entire array, we can perform an operation
if (current > 0) {
operations++;
// Double the size of the uniform subarray by considering the previous non-uniform part
last_pos = current - 1;
} else {
// If we have reached the beginning of the array, break
break;
}
}
cout << operations << endl;
}
return 0;
}
詳細信息
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3572kb
input:
4 2 1 2 2 2 2 7 1 1 1 2 2 2 2 3 1 2 3
output:
1 0 1 2
result:
wrong answer 3rd numbers differ - expected: '3', found: '1'