結果
問題 | No.1765 While Shining |
ユーザー |
![]() |
提出日時 | 2021-11-26 23:29:03 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,082 bytes |
コンパイル時間 | 1,484 ms |
コンパイル使用メモリ | 168,528 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-06-29 18:35:14 |
合計ジャッジ時間 | 2,501 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | WA * 22 |
ソースコード
#include <bits/stdc++.h> using namespace std; using ll = long long; using Graph = vector<vector<int> >; #define rep(i, a, b) for(int i = a; i < b; i++) #define rrep(i, a, b) for(int i = a; i >= b; i--) #define fore(i, a) for(auto &i:a) #define all(x) (x).begin(),(x).end() const int INFI = 1 << 29; const ll INFL = 1LL << 59; int main() { cin.tie(0); ios::sync_with_stdio(false); int n; cin >> n; vector<int> A(n); fore (i, A) cin >> i; bool swtch = true; ll tmp = 0, ans = 0; rep(i, 0, n) { if (A[i] == 1 and swtch == true) { tmp++; swtch = false; } else if (A[i] == 0 and swtch == false) { tmp++; swtch = true; } else { ans += tmp; tmp; ll tmp2 = (tmp / 2); ans += tmp2 * (tmp2 + 1) / 2; if (A[i] == 1) tmp = 0, swtch = false; else tmp = 0, swtch = true; } } ans += tmp; tmp; ll tmp2 = (tmp / 2); ans += tmp2 * (tmp2 + 1) / 2; cout << ans << endl; }