結果
問題 |
No.2860 Heal Slimes
|
ユーザー |
![]() |
提出日時 | 2024-08-25 15:59:50 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 75 ms / 2,000 ms |
コード長 | 1,824 bytes |
コンパイル時間 | 1,957 ms |
コンパイル使用メモリ | 197,248 KB |
最終ジャッジ日時 | 2025-02-24 01:38:09 |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 60 |
ソースコード
#include <bits/stdc++.h> using namespace std; #define all(v) (v).begin(),(v).end() #define pb(a) push_back(a) #define rep(i, n) for(int i=0;i<n;i++) #define foa(e, v) for(auto& e : v) using ll = long long; const ll MOD7 = 1000000007, MOD998 = 998244353, INF = (1LL << 60); #define dout(a) cout<<fixed<<setprecision(10)<<a<<endl; void solve() { ll n, k, x; cin >> n >> k >> x; vector<ll> a(n), b(n + 1, 0); rep(i, n) cin >> a[i]; rep(i, n - 1) b[i + 1] = a[i + 1] - a[i]; bool ng = 0; foa(e, b) if(e % x) ng = 1; if(ng) { cout << "No" << endl; return; } rep(i, k) { if(i == 0) { if(n % k == i) { continue; } else { ll sum = 0; for(int j = i; j < n; j += k) { sum += b[j]; if(sum > 0) { sum = 0; } } if(sum < 0) ng = true; } } else { if(n % k == i) { ll sum = 0; for(int j = i; j < n; j += k) { sum += b[j]; if(sum > 0) { ng = true; break; } } if(sum > 0) ng = true; } else { ll sum = 0; for(int j = i; j < n; j += k) { sum += b[j]; if(sum > 0) { ng = true; break; } } if(sum) ng = true; } } } cout << (ng ? "No" : "Yes") << endl; } int main() { cin.tie(0); ios::sync_with_stdio(false); int t; cin >> t; while(t --) solve(); return 0; }