結果
問題 | No.1505 Zero-Product Ranges |
ユーザー |
![]() |
提出日時 | 2021-05-20 05:51:10 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 667 bytes |
コンパイル時間 | 844 ms |
コンパイル使用メモリ | 69,816 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-10-10 07:10:11 |
合計ジャッジ時間 | 7,222 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 WA * 2 |
other | AC * 2 WA * 47 |
ソースコード
#include <iostream> #include <vector> typedef long long ll; using namespace std; template<typename H> void print(H head) { cout << head << endl; } template<typename H, typename... T> void print(H&& head, T&&... tail){ std::cout << head << " ", print(std::forward<T>(tail)...); } int main() { ll N; cin >> N; std::vector<ll> va(N); for (auto& a : va) cin >> a; ll cnt = 0LL; ll ans = 0LL; for (ll i = 0; i < N; i++) { if (va[i] == 0) { ans += cnt * (cnt + 1) / 2; print(i, cnt, ans); cnt = 0; } else { cnt++; } } ans += cnt * (cnt + 1) / 2; ll ans2 = N * (N+1) / 2 - ans; print(ans2); return 0; }