QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#694812#6604. Kobolds and Catacombsnahida_qaqWA 884ms89128kbC++231.0kb2024-10-31 18:43:102024-10-31 18:43:11

Judging History

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

  • [2024-10-31 18:43:11]
  • 评测
  • 测评结果:WA
  • 用时:884ms
  • 内存:89128kb
  • [2024-10-31 18:43:10]
  • 提交

answer

#include <bits/stdc++.h>
#define int long long
#define io ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define pb push_back
using namespace std;
const int N=1e6+5,mod1=1e9+7,mod2=998244353;
typedef pair<int,int> pi;
int a[N],b[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,mp1;
    for(int i=1;i<=n;i++)mp[b[i]]=i;
    for(int i=1;i<=n;i++)a[i]=mp[a[i]];
    queue<pi>q;
    for(int i=1;i<=n;i++)
    {
        if(i<=a[i])
        {
            q.push({i,a[i]});
            //cout<<i<<' '<<a[i]<<'\n';
        }
    }
    int ans=1;
    int ll=1,rr=q.front().second;
    q.pop();
    while(q.size())
    {
        int l=q.front().first,r=q.front().second;
        q.pop();
        if(l>rr)
        {
            ans++;
            ll=l,rr=r;
        }
        else rr=r;
    }
    cout<<ans;
}
signed main()
{
    io;
    int t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

5
1 3 2 7 4

output:

3

result:

ok 1 number(s): "3"

Test #2:

score: -100
Wrong Answer
time: 884ms
memory: 89128kb

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:

10

result:

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