結果

問題 No.1055 牛歩
ユーザー 夕叢霧香(ゆうむらきりか)夕叢霧香(ゆうむらきりか)
提出日時 2019-09-29 01:19:13
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,442 bytes
コンパイル時間 643 ms
コンパイル使用メモリ 79,528 KB
実行使用メモリ 20,736 KB
最終ジャッジ日時 2023-08-18 17:14:08
合計ジャッジ時間 4,824 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 111 ms
20,736 KB
testcase_01 AC 68 ms
20,448 KB
testcase_02 AC 45 ms
16,236 KB
testcase_03 AC 47 ms
16,272 KB
testcase_04 AC 47 ms
16,272 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 45 ms
15,864 KB
testcase_08 WA -
testcase_09 AC 37 ms
15,580 KB
testcase_10 AC 37 ms
15,648 KB
testcase_11 WA -
testcase_12 AC 39 ms
15,120 KB
testcase_13 AC 38 ms
15,128 KB
testcase_14 AC 39 ms
16,000 KB
testcase_15 AC 39 ms
15,956 KB
testcase_16 AC 34 ms
15,296 KB
testcase_17 WA -
testcase_18 AC 34 ms
15,432 KB
testcase_19 WA -
testcase_20 AC 43 ms
15,964 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 50 ms
16,640 KB
testcase_24 AC 50 ms
16,636 KB
testcase_25 AC 32 ms
15,528 KB
testcase_26 WA -
testcase_27 AC 38 ms
15,712 KB
testcase_28 WA -
testcase_29 AC 36 ms
15,688 KB
testcase_30 AC 40 ms
15,692 KB
testcase_31 AC 13 ms
13,980 KB
testcase_32 AC 12 ms
13,916 KB
testcase_33 AC 12 ms
13,984 KB
testcase_34 AC 11 ms
13,868 KB
testcase_35 AC 14 ms
14,008 KB
testcase_36 AC 14 ms
14,012 KB
testcase_37 AC 12 ms
13,900 KB
testcase_38 AC 14 ms
13,924 KB
testcase_39 AC 6 ms
13,676 KB
testcase_40 AC 7 ms
13,768 KB
testcase_41 AC 5 ms
13,636 KB
testcase_42 AC 6 ms
13,784 KB
testcase_43 AC 6 ms
13,696 KB
testcase_44 AC 6 ms
13,656 KB
testcase_45 AC 6 ms
13,672 KB
testcase_46 AC 6 ms
13,696 KB
testcase_47 AC 6 ms
13,680 KB
testcase_48 AC 5 ms
13,780 KB
testcase_49 AC 5 ms
13,648 KB
testcase_50 AC 6 ms
13,776 KB
testcase_51 AC 5 ms
13,628 KB
testcase_52 AC 5 ms
13,784 KB
testcase_53 AC 5 ms
13,596 KB
testcase_54 AC 5 ms
13,604 KB
testcase_55 AC 5 ms
13,596 KB
testcase_56 AC 5 ms
13,724 KB
testcase_57 AC 5 ms
13,580 KB
testcase_58 AC 6 ms
13,580 KB
testcase_59 AC 6 ms
13,712 KB
testcase_60 AC 5 ms
13,684 KB
testcase_61 AC 5 ms
13,596 KB
testcase_62 AC 5 ms
13,644 KB
testcase_63 AC 5 ms
13,584 KB
testcase_64 AC 5 ms
13,796 KB
testcase_65 AC 5 ms
13,672 KB
testcase_66 AC 5 ms
13,672 KB
testcase_67 AC 5 ms
13,692 KB
testcase_68 AC 5 ms
13,576 KB
testcase_69 AC 5 ms
13,592 KB
testcase_70 AC 5 ms
13,572 KB
testcase_71 AC 5 ms
13,644 KB
testcase_72 WA -
testcase_73 AC 5 ms
13,596 KB
testcase_74 AC 5 ms
13,584 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<algorithm>
#include<iostream>
#include<vector>
#include<cassert>
using namespace std;
typedef long long lint;
typedef vector<int>vi;
typedef pair<int,int>pii;
#define rep(i,n)for(int i=0;i<(int)(n);++i)

#define DEBUG 0

#define M 214514
int n,m,q;
int a[M],b[M];
vi tu[M];
vi mv[M];

int main(){
  cin>>n>>m;
  rep(i,m)cin>>a[i];
  cin>>q;
  rep(i,q)cin>>b[i];
  //assert
  assert(1<=n&&n<=1000000);
  assert(1<=m&&m<=n&&n<=200000);
  rep(i,m-1)assert(a[i]<a[i+1]);
  rep(i,m)assert(1<=a[i]&&a[i]<=n);
  rep(i,q)assert(1<=b[i]&&b[i]<=m);
  //解
  rep(i,q)tu[b[i]-1].push_back(i);
  rep(i,m){
    int p=a[i];
    mv[i].push_back(p);
    int pp=0;
    rep(j,tu[i].size()+1){
      int t=j==(int)tu[i].size()?q:tu[i][j];
      int pre;
      if(i==0)pre=0;
      else{
        int it=lower_bound(tu[i-1].begin(),tu[i-1].end(),t)-tu[i-1].begin();
        pre=mv[i-1][it];
        if(it+1<mv[i-1].size())pre=max(pre,mv[i-1][it+1]);
        if(DEBUG)cerr<<i<<"-"<<j<<"-"<<pre<<"@"<<t<<endl;
        while(pp<=it){
          if(mv[i-1][pp]>=p){
            cout<<"NO"<<endl;return 0;
          }
          pp++;
        }
        pp--;
      }
      if(j>=tu[i].size())break;
      mv[i].push_back(pre<p-1?--p:++p);
      if(p>n){
        cout<<"NO"<<endl;return 0;
      }
      
    }
    if(DEBUG){
      cerr<<mv[i][0];
      rep(j,tu[i].size())cerr<<" "<<tu[i][j]<<","<<mv[i][j+1];
      cerr<<endl;
    }
  }
  cout<<"YES"<<endl;
}
0