結果
問題 |
No.3305 Shift Sort
|
ユーザー |
|
提出日時 | 2025-10-05 15:29:43 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
RE
|
実行時間 | - |
コード長 | 740 bytes |
コンパイル時間 | 3,186 ms |
コンパイル使用メモリ | 284,344 KB |
実行使用メモリ | 7,732 KB |
最終ジャッジ日時 | 2025-10-05 15:30:08 |
合計ジャッジ時間 | 16,035 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | WA * 5 RE * 15 |
ソースコード
#include<bits/stdc++.h> using namespace std; using ll =long long; int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); ll N,Q; cin>>N>>Q; vector<ll> P(N); for(int i=0;i<N;i++){ cin>>P[i]; P[i]=N-P[i]; } reverse(P.begin(),P.end()); ll SS=0; for(int q=0;q<Q;q++){ ll L,R; cin>>L>>R; L--; ll an=R-L; ll pp=N-L; SS+=R-L; if(SS>1e7)assert(0); L=N-R; R=pp; vector<ll> D={P.begin()+L,P.begin()+R}; sort(D.begin(),D.end()); ll t=0; for(int j=L;j<R;j++){ if(t<D.size()&&P[j]==D[t]){ t++; } } cout<<an-t<<"\n"; } }