QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#689282#9313. Make Maxviolet-WA 1ms3572kbC++14634b2024-10-30 16:10:442024-10-30 16:10:44

Judging History

你现在查看的是最新测评结果

  • [2024-10-30 16:10:44]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3572kb
  • [2024-10-30 16:10:44]
  • 提交

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'