QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#694998#6604. Kobolds and CatacombsMocic1RE 0ms3632kbC++14948b2024-10-31 19:06:182024-10-31 19:06:23

Judging History

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

  • [2024-10-31 19:06:23]
  • 评测
  • 测评结果:RE
  • 用时:0ms
  • 内存:3632kb
  • [2024-10-31 19:06:18]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

#define ios ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
//#define int long long
#define pb push_back
#define ff first
#define ss second
typedef pair<int, int> pi;
const int N = 300007;
const int inf = 1e18;
const int mod = 1e9+7;
mt19937_64 rng(time(0));


int a[N],b[N],sum[N];
void solve()
{
    int n;
    cin>>n;
    for(int i=1;i<=n;i++)cin>>a[i],b[i]=a[i];
    sort(b+1,b+1+n);
    map<int,int>mp;
    for(int i=1;i<=n;i++)mp[b[i]]=i;
    for(int i=1;i<=n;i++){
        int mn=min(i,mp[a[i]]);
        int mx=max(i,mp[a[i]]);
        sum[mn]++;
        sum[mx]--;
    }
    int ans=0;
    for(int i=1;i<=n;i++){
        sum[i]=sum[i-1]+sum[i];
        if(sum[i]==0){
            ans++;
        }
    }
    cout<<ans<<'\n';

    
}
signed main() {
    ios;
    int _ = 1;
    //cin >> _;
    while (_--) {
        solve();
    }
    return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 0ms
memory: 3632kb

input:

5
1 3 2 7 4

output:

3

result:

ok 1 number(s): "3"

Test #2:

score: -100
Runtime Error

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: