結果

問題 No.1055 牛歩
ユーザー root__786root__786
提出日時 2020-05-22 15:06:50
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 65 ms / 1,000 ms
コード長 1,931 bytes
コンパイル時間 2,582 ms
コンパイル使用メモリ 200,512 KB
実行使用メモリ 18,880 KB
最終ジャッジ日時 2024-04-15 04:59:10
合計ジャッジ時間 5,458 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 65 ms
18,880 KB
testcase_01 AC 32 ms
16,576 KB
testcase_02 AC 20 ms
14,852 KB
testcase_03 AC 20 ms
14,784 KB
testcase_04 AC 21 ms
14,912 KB
testcase_05 AC 20 ms
14,912 KB
testcase_06 AC 21 ms
14,784 KB
testcase_07 AC 20 ms
14,912 KB
testcase_08 AC 22 ms
14,912 KB
testcase_09 AC 18 ms
15,016 KB
testcase_10 AC 19 ms
14,652 KB
testcase_11 AC 19 ms
14,656 KB
testcase_12 AC 22 ms
15,552 KB
testcase_13 AC 22 ms
15,420 KB
testcase_14 AC 19 ms
14,528 KB
testcase_15 AC 20 ms
14,532 KB
testcase_16 AC 17 ms
14,656 KB
testcase_17 AC 17 ms
14,496 KB
testcase_18 AC 17 ms
14,784 KB
testcase_19 AC 17 ms
14,696 KB
testcase_20 AC 20 ms
15,428 KB
testcase_21 AC 21 ms
14,912 KB
testcase_22 AC 22 ms
15,164 KB
testcase_23 AC 22 ms
15,164 KB
testcase_24 AC 21 ms
15,168 KB
testcase_25 AC 19 ms
14,528 KB
testcase_26 AC 18 ms
15,132 KB
testcase_27 AC 18 ms
14,572 KB
testcase_28 AC 18 ms
14,452 KB
testcase_29 AC 21 ms
14,952 KB
testcase_30 AC 19 ms
14,440 KB
testcase_31 AC 8 ms
13,376 KB
testcase_32 AC 8 ms
13,508 KB
testcase_33 AC 9 ms
13,476 KB
testcase_34 AC 8 ms
13,628 KB
testcase_35 AC 9 ms
13,520 KB
testcase_36 AC 8 ms
13,252 KB
testcase_37 AC 8 ms
13,380 KB
testcase_38 AC 8 ms
13,636 KB
testcase_39 AC 4 ms
13,120 KB
testcase_40 AC 4 ms
12,996 KB
testcase_41 AC 4 ms
13,124 KB
testcase_42 AC 5 ms
13,120 KB
testcase_43 AC 5 ms
13,120 KB
testcase_44 AC 5 ms
12,992 KB
testcase_45 AC 5 ms
13,120 KB
testcase_46 AC 5 ms
13,120 KB
testcase_47 AC 5 ms
12,992 KB
testcase_48 AC 4 ms
13,460 KB
testcase_49 AC 4 ms
13,312 KB
testcase_50 AC 4 ms
13,124 KB
testcase_51 AC 5 ms
12,992 KB
testcase_52 AC 5 ms
13,040 KB
testcase_53 AC 4 ms
13,120 KB
testcase_54 AC 5 ms
12,988 KB
testcase_55 AC 5 ms
12,992 KB
testcase_56 AC 6 ms
13,252 KB
testcase_57 AC 4 ms
12,992 KB
testcase_58 AC 5 ms
12,996 KB
testcase_59 AC 4 ms
12,992 KB
testcase_60 AC 4 ms
12,992 KB
testcase_61 AC 4 ms
13,120 KB
testcase_62 AC 5 ms
13,252 KB
testcase_63 AC 4 ms
13,120 KB
testcase_64 AC 5 ms
12,992 KB
testcase_65 AC 5 ms
13,532 KB
testcase_66 AC 5 ms
13,120 KB
testcase_67 AC 4 ms
13,504 KB
testcase_68 AC 5 ms
12,992 KB
testcase_69 AC 4 ms
13,484 KB
testcase_70 AC 4 ms
13,248 KB
testcase_71 AC 4 ms
12,988 KB
testcase_72 AC 4 ms
13,040 KB
testcase_73 AC 5 ms
13,124 KB
testcase_74 AC 4 ms
12,988 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