QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#689282 | #9313. Make Max | violet- | WA | 1ms | 3572kb | C++14 | 634b | 2024-10-30 16:10:44 | 2024-10-30 16:10:44 |
Judging History
answer
#include <iostream>
#include <vector>
using namespace std;
int main() {
int t;
cin >> t;
while (t--) {
int n;
cin >> n;
vector<int> nums(n);
for (int i = 0; i < n; ++i) {
cin >> nums[i];
}
vector<int> prefixMax(n), suffixMax(n);
prefixMax[0] = nums[0];
for (int i = 1; i < n; ++i) {
prefixMax[i] = max(prefixMax[i-1], nums[i]);
}
suffixMax[n-1] = nums[n-1];
for (int i = n-2; i >= 0; --i) {
suffixMax[i] = max(suffixMax[i+1], nums[i]);
}
int maxOps = 0;
for (int i = 0; i < n; ++i) {
if (prefixMax[i] != suffixMax[i]) {
maxOps++;
}
}
cout << maxOps << endl;
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 1ms
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 3 2
result:
wrong answer 4th numbers differ - expected: '3', found: '2'