QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#112090#6604. Kobolds and Catacombszararaza#WA 2ms3440kbC++17642b2023-06-09 23:05:212023-06-09 23:05:25

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-06-09 23:05:25]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:3440kb
  • [2023-06-09 23:05:21]
  • 提交

answer

#include<set>
#include<iostream>
#include<vector>
#include<map>

using namespace std;

int main() {
    cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false);
    int n; cin >> n;
    vector<int> v(n), pref_max(n), suf_min(n);
    for (int i = 0; i < n; i++) cin >> v[i];
    for (int i = 0; i < n; i++) {
        pref_max[i] = i == 0 ? v[i] : max(pref_max[i-1], v[i]);
    }
    for (int i = n-1; i > -1; i--) {
        suf_min[i] = i == n-1 ? v[i] : min(v[i], suf_min[i+1]);
    }
    int res = 0;
    for (int i = 0; i < n; i++) {
        if (pref_max[i] <= suf_min[i+1]) res++;
    }
    cout << res << endl; 
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 2ms
memory: 3440kb

input:

5
1 3 2 7 4

output:

2

result:

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