QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#695004#6604. Kobolds and CatacombsMocic1TL 1ms7936kbC++14949b2024-10-31 19:06:562024-10-31 19:06:56

Judging History

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

  • [2024-10-31 19:06:56]
  • 评测
  • 测评结果:TL
  • 用时:1ms
  • 内存:7936kb
  • [2024-10-31 19:06:56]
  • 提交

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 = 3000007;
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;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 7936kb

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: