結果

問題 No.1055 牛歩
ユーザー kriii
提出日時 2020-05-15 23:03:35
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 43 ms / 1,000 ms
コード長 623 bytes
コンパイル時間 379 ms
コンパイル使用メモリ 27,776 KB
最終ジャッジ日時 2025-01-10 12:07:44
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 5
other AC * 70
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:7:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    7 |         scanf("%d %d", &N, &M);
      |         ~~~~~^~~~~~~~~~~~~~~~~
main.cpp:9:23: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    9 |                 scanf ("%d", &A[i]);
      |                 ~~~~~~^~~~~~~~~~~~~
main.cpp:16:15: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   16 |         scanf ("%d", &Q); while (Q--){
      |         ~~~~~~^~~~~~~~~~
main.cpp:17:30: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   17 |                 int i; scanf ("%d", &i);
      |                        ~~~~~~^~~~~~~~~~

ソースコード

diff #

#include <stdio.h>

int N, M, Q, A[200200], L[200200], R[200200];

int main()
{
	scanf("%d %d", &N, &M);
	for (int i = 1; i <= M; i++){
		scanf ("%d", &A[i]);
		A[i] -= i;
		L[i] = R[i] = A[i];
	}
	N -= M;
	L[M + 1] = R[M + 1] = N;

	scanf ("%d", &Q); while (Q--){
		int i; scanf ("%d", &i);
		L[i]--; R[i]++;
		for (int j = i; j <= N; j++){
			if (L[j] < L[j - 1]) L[j] += 2;
			else break;
			if (L[j] > R[j]){
				puts("NO");
				return 0;
			}
		}
		for (int j = i; j >= 1; j--){
			if (R[j] > R[j + 1]) R[j] -= 2;
			else break;
			if (L[j] > R[j]){
				puts("NO");
				return 0;
			}
		}
	}
	puts("YES");
	return 0;
}
0