結果

問題 No.1055 牛歩
ユーザー 👑 kmjpkmjp
提出日時 2020-05-16 12:19:38
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 79 ms / 1,000 ms
コード長 1,932 bytes
コンパイル時間 3,258 ms
コンパイル使用メモリ 207,696 KB
実行使用メモリ 18,804 KB
最終ジャッジ日時 2023-10-22 08:01:48
合計ジャッジ時間 5,635 ms
ジャッジサーバーID
(参考情報)
judge11 / judge9
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 79 ms
18,804 KB
testcase_01 AC 36 ms
16,604 KB
testcase_02 AC 23 ms
14,756 KB
testcase_03 AC 24 ms
14,756 KB
testcase_04 AC 24 ms
14,756 KB
testcase_05 AC 24 ms
14,756 KB
testcase_06 AC 27 ms
15,124 KB
testcase_07 AC 24 ms
15,076 KB
testcase_08 AC 27 ms
15,124 KB
testcase_09 AC 22 ms
14,492 KB
testcase_10 AC 22 ms
14,492 KB
testcase_11 AC 22 ms
14,492 KB
testcase_12 AC 25 ms
15,544 KB
testcase_13 AC 25 ms
15,544 KB
testcase_14 AC 22 ms
14,708 KB
testcase_15 AC 23 ms
14,708 KB
testcase_16 AC 19 ms
14,728 KB
testcase_17 AC 20 ms
14,228 KB
testcase_18 AC 20 ms
14,728 KB
testcase_19 AC 20 ms
14,228 KB
testcase_20 AC 23 ms
15,316 KB
testcase_21 AC 24 ms
15,112 KB
testcase_22 AC 25 ms
15,020 KB
testcase_23 AC 25 ms
15,020 KB
testcase_24 AC 26 ms
15,020 KB
testcase_25 AC 21 ms
14,544 KB
testcase_26 AC 21 ms
14,544 KB
testcase_27 AC 23 ms
14,456 KB
testcase_28 AC 22 ms
14,464 KB
testcase_29 AC 23 ms
14,736 KB
testcase_30 AC 23 ms
14,460 KB
testcase_31 AC 10 ms
13,492 KB
testcase_32 AC 10 ms
13,524 KB
testcase_33 AC 10 ms
13,492 KB
testcase_34 AC 10 ms
13,520 KB
testcase_35 AC 10 ms
13,492 KB
testcase_36 AC 11 ms
13,492 KB
testcase_37 AC 10 ms
13,524 KB
testcase_38 AC 10 ms
13,524 KB
testcase_39 AC 6 ms
13,168 KB
testcase_40 AC 7 ms
13,136 KB
testcase_41 AC 7 ms
13,172 KB
testcase_42 AC 7 ms
13,172 KB
testcase_43 AC 7 ms
13,168 KB
testcase_44 AC 7 ms
13,168 KB
testcase_45 AC 7 ms
13,136 KB
testcase_46 AC 7 ms
13,172 KB
testcase_47 AC 6 ms
13,140 KB
testcase_48 AC 6 ms
13,048 KB
testcase_49 AC 6 ms
13,080 KB
testcase_50 AC 6 ms
13,080 KB
testcase_51 AC 6 ms
13,052 KB
testcase_52 AC 6 ms
13,084 KB
testcase_53 AC 6 ms
13,064 KB
testcase_54 AC 6 ms
13,064 KB
testcase_55 AC 6 ms
13,064 KB
testcase_56 AC 6 ms
13,064 KB
testcase_57 AC 6 ms
13,096 KB
testcase_58 AC 6 ms
13,064 KB
testcase_59 AC 7 ms
13,068 KB
testcase_60 AC 6 ms
13,068 KB
testcase_61 AC 6 ms
13,100 KB
testcase_62 AC 6 ms
13,100 KB
testcase_63 AC 6 ms
13,100 KB
testcase_64 AC 6 ms
13,068 KB
testcase_65 AC 6 ms
13,100 KB
testcase_66 AC 6 ms
13,048 KB
testcase_67 AC 6 ms
13,048 KB
testcase_68 AC 6 ms
13,080 KB
testcase_69 AC 6 ms
13,080 KB
testcase_70 AC 6 ms
13,048 KB
testcase_71 AC 6 ms
13,080 KB
testcase_72 AC 6 ms
13,052 KB
testcase_73 AC 6 ms
13,084 KB
testcase_74 AC 6 ms
13,084 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------


int N,M,Q;
int A[202020];
vector<pair<int,int>> T[202020];
vector<int> ev[202020];
void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>M;
	FOR(i,M) {
		cin>>A[i];
		A[i]--;
		T[i].push_back({0,0});
	}
	cin>>Q;
	FOR(i,Q) {
		cin>>x;
		T[x-1].push_back({i+1,0});
	}
	FOR(i,M) {
		int cur=A[i];
		if(i==0) {
			T[0][0].second=A[0];
			FOR(x,T[i].size()) if(x) {
				T[i][x].second=T[i][x-1].second;
				if(T[i][x].second>0) T[i][x].second--;
				else T[i][x].second++;
				if(T[i][x].second>=N) return _P("NO\n");
			}
		}
		else {
			x=0;
			y=0;
			T[i][0].second=A[i-1];
			while(x<T[i].size()-1||y<T[i-1].size()-1) {
				if(x<T[i].size()-1&&y<T[i-1].size()-1) {
					if(T[i][x+1].first<T[i-1][y+1].first) x++;
					else y++;
				}
				else if(x<T[i].size()-1) {
					x++;
					
				}
				else {
					y++;
				}
				T[i][x].second=max(T[i][x].second,T[i-1][y].second);
			}
			FOR(x,T[i].size()-1) T[i][x+1].second=max(T[i][x+1].second,T[i][x].second-1);
			for(x=T[i].size()-2;x>=0;x--) T[i][x].second=max(T[i][x].second,T[i][x+1].second-1);
			cur=A[i];
			FORR(t,T[i]) {
				if(t.first>0) {
					if(t.second<cur-1) cur--;
					else cur++;
				}
				if(cur<=t.second || cur>=N) return _P("NO\n");
				t.second=cur;
			}
		}
	}
	cout<<"YES"<<endl;
	
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}
0