QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#112089#6604. Kobolds and Catacombszararaza#TL 2ms3340kbC++17714b2023-06-09 22:53:122023-06-09 22:53:15

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 22:53:15]
  • 评测
  • 测评结果:TL
  • 用时:2ms
  • 内存:3340kb
  • [2023-06-09 22:53:12]
  • 提交

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);
    for (int i = 0; i < n; i++) cin >> v[i];
    
    map<int, int> s;
    for (int a : v) s[a]++;
    int res = 0;
    for (int i = 0; i < n; ) {
        int maxi = v[i];
        while (true) {
            s[v[i]]--;
            if (s[v[i]] == 0) s.erase(v[i]);
            if (maxi < v[i]) maxi = v[i];
            i++;
            if (i == n || maxi <= s.begin()->first) {
                res++;
                break;
            }
        }
    }
    cout << res << endl;
}

詳細信息

Test #1:

score: 100
Accepted
time: 2ms
memory: 3340kb

input:

5
1 3 2 7 4

output:

3

result:

ok 1 number(s): "3"

Test #2:

score: -100
Time Limit Exceeded

input:

1000000
524227301 431992275 758916082 293029389 719487809 413407585 7533705 414925441 87316769 639877621 980912701 739058961 277730843 958292661 778325685 500280161 782766985 339709027 1968001 842653531 847517701 989893001 97622801 728458741 612188545 787566057 981715521 281901909 804267925 89113887...

output:


result: