QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#574604#9313. Make MaxyylxWA 0ms3556kbC++14959b2024-09-18 23:12:042024-09-18 23:12:06

Judging History

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

  • [2024-09-18 23:12:06]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3556kb
  • [2024-09-18 23:12:04]
  • 提交

answer

#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
    int t;
    cin >> t;

    while (t--) {
        int n;
        cin >> n;
        vector<int> a(n);
        for (int i = 0; i < n; ++i) {
            cin >> a[i];
        }

        int operations = 0;
        int currentMax = a[0];
        int distinctCount = 1; // Count of distinct elements encountered so far

        for (int i = 1; i < n; ++i) {
            if (a[i] > currentMax) {
                currentMax = a[i];
                distinctCount = 1; // Reset distinct count as we found a new max
            } else if (a[i] < currentMax) {
                ++distinctCount;
            }

            if (distinctCount > 1) {
                ++operations;
                distinctCount = 1; // Reset after performing an operation
            }
        }

        cout << operations << endl;
    }

    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3556kb

input:

4
2
1 2
2
2 2
7
1 1 1 2 2 2 2
3
1 2 3

output:

0
0
0
0

result:

wrong answer 1st numbers differ - expected: '1', found: '0'