結果

問題 No.2860 Heal Slimes
ユーザー 沙耶花沙耶花
提出日時 2024-08-25 15:17:48
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 108 ms / 2,000 ms
コード長 1,192 bytes
コンパイル時間 4,626 ms
コンパイル使用メモリ 269,668 KB
実行使用メモリ 7,148 KB
最終ジャッジ日時 2024-08-25 15:18:01
合計ジャッジ時間 11,667 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 106 ms
6,816 KB
testcase_01 AC 101 ms
6,940 KB
testcase_02 AC 102 ms
6,940 KB
testcase_03 AC 101 ms
6,940 KB
testcase_04 AC 108 ms
6,940 KB
testcase_05 AC 105 ms
6,940 KB
testcase_06 AC 107 ms
6,940 KB
testcase_07 AC 108 ms
6,940 KB
testcase_08 AC 106 ms
6,940 KB
testcase_09 AC 106 ms
6,940 KB
testcase_10 AC 77 ms
6,944 KB
testcase_11 AC 72 ms
6,940 KB
testcase_12 AC 77 ms
6,940 KB
testcase_13 AC 74 ms
6,940 KB
testcase_14 AC 75 ms
6,940 KB
testcase_15 AC 83 ms
6,944 KB
testcase_16 AC 77 ms
6,940 KB
testcase_17 AC 77 ms
6,940 KB
testcase_18 AC 78 ms
6,940 KB
testcase_19 AC 77 ms
6,940 KB
testcase_20 AC 59 ms
6,940 KB
testcase_21 AC 63 ms
6,944 KB
testcase_22 AC 39 ms
6,940 KB
testcase_23 AC 86 ms
7,004 KB
testcase_24 AC 73 ms
6,944 KB
testcase_25 AC 42 ms
6,940 KB
testcase_26 AC 35 ms
6,940 KB
testcase_27 AC 70 ms
6,940 KB
testcase_28 AC 74 ms
6,940 KB
testcase_29 AC 52 ms
6,940 KB
testcase_30 AC 68 ms
7,016 KB
testcase_31 AC 72 ms
7,020 KB
testcase_32 AC 69 ms
7,092 KB
testcase_33 AC 62 ms
7,020 KB
testcase_34 AC 76 ms
6,940 KB
testcase_35 AC 66 ms
7,148 KB
testcase_36 AC 58 ms
7,012 KB
testcase_37 AC 65 ms
7,020 KB
testcase_38 AC 66 ms
7,016 KB
testcase_39 AC 68 ms
7,144 KB
testcase_40 AC 82 ms
7,016 KB
testcase_41 AC 79 ms
7,016 KB
testcase_42 AC 77 ms
7,016 KB
testcase_43 AC 80 ms
7,016 KB
testcase_44 AC 87 ms
7,016 KB
testcase_45 AC 80 ms
7,008 KB
testcase_46 AC 79 ms
7,140 KB
testcase_47 AC 83 ms
7,016 KB
testcase_48 AC 80 ms
7,016 KB
testcase_49 AC 81 ms
7,016 KB
testcase_50 AC 81 ms
7,016 KB
testcase_51 AC 80 ms
7,016 KB
testcase_52 AC 79 ms
7,020 KB
testcase_53 AC 80 ms
7,144 KB
testcase_54 AC 80 ms
7,016 KB
testcase_55 AC 81 ms
7,016 KB
testcase_56 AC 81 ms
7,148 KB
testcase_57 AC 87 ms
7,020 KB
testcase_58 AC 81 ms
7,012 KB
testcase_59 AC 80 ms
7,140 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace atcoder;
using mint = modint998244353;
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define Inf32 1000000001
#define Inf64 1000000000000000001

int main(){
	int _t;
	cin>>_t;
	rep(_,_t){
		long long N,K,X;
		cin>>N>>K>>X;
		vector<long long> h(N);
		rep(i,N)cin>>h[i];
		vector<long long> d(1,h[0]);
		rep(i,N-1){
			d.push_back(h[i+1]-h[i]);
		}
		d.push_back(-h[N-1]);
		{
			set<long long> ss;
			for(int i=1;i<N;i++){
				if(d[i]%X!=0){
					ss.insert(0);
					ss.insert(1);
					break;
				}
			}
			if(ss.size()>=2){
				cout<<"No"<<endl;
				continue;
			}
		}
		bool f=  true;
		rep(i,K){
			bool F0 = false,F1 = false;
			long long sum = 0;
			for(int j=i;j<=N;j+=K){
				if(j==0){
					continue;
				}
				if(j==N){
					continue;
				}
				if(d[j]==0)continue;
				if(d[j]>0){
					if(i==0){
						d[j] = 0;
					}
					else{
					f = false;
					break;
					}
				}
				else{
					if(j+K>N){
						f=  false;
						break;
					}
					else{
						d[j+K] += d[j];
						d[j] = 0;
					}
				}
			}
			
		}
		if(f)cout<<"Yes"<<endl;
		else cout<<"No"<<endl;
	}
    return 0;
}
0