結果
| 問題 |
No.1219 Mancala Combo
|
| コンテスト | |
| ユーザー |
Atomic67
|
| 提出日時 | 2020-09-08 23:29:49 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 25 ms / 2,000 ms |
| コード長 | 1,366 bytes |
| コンパイル時間 | 1,595 ms |
| コンパイル使用メモリ | 168,092 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-11-30 12:42:35 |
| 合計ジャッジ時間 | 2,944 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 26 |
ソースコード
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
using namespace std;
using ll = long long;
template<class T> inline bool chmin(T& a, T b) {
if(a > b) {
a = b;
return true;
}
return false;
}
template<class T> inline bool chmax(T& a, T b) {
if(a < b) {
a = b;
return true;
}
return false;
}
struct Unionfind {
vector<int> par;
Unionfind(int n) : par(n) {
for(int i = 0; i < n; ++i) par[i] = i;
}
int root(int x) {
if(par[x] == x) return x;
return par[x] = root(par[x]);
}
void unite(int x, int y) {
int rx = root(x);
int ry = root(y);
if(rx == ry) return;
par[rx] =ry;
}
bool same(int x, int y) {
int rx = root(x);
int ry = root(y);
return rx == ry;
}
};
int main() {
cin.tie(nullptr);
ios_base::sync_with_stdio(false);
int n;
cin >> n;
vector<int> a(n+1);
for(int i = 1; i <= n; ++i) {
cin >> a[i];
if(a[i] > i) {
cout << "No" << endl;
return 0;
}
}
ll v = 0;
for(int i = n; i >= 1; --i) {
if((ll(a[i]) + v) % i != 0) {
cout << "No" << endl;
return 0;
}
v += (a[i] + v) / i;
}
cout << "Yes" << endl;
return 0;
}
Atomic67