結果
問題 | No.1505 Zero-Product Ranges |
ユーザー |
![]() |
提出日時 | 2022-11-05 13:53:32 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 19 ms / 2,000 ms |
コード長 | 432 bytes |
コンパイル時間 | 1,281 ms |
コンパイル使用メモリ | 166,952 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-07-19 07:29:44 |
合計ジャッジ時間 | 3,581 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 49 |
ソースコード
#include <bits/stdc++.h>using namespace std;int main(){int N;long sum = 0;int length = 0;int t;scanf("%d",&N);for(int i=0;i<N;i++){scanf("%d",&t);if(t == 1){length++;} else {sum += (long)length*((long)length+1)/2;length = 0;}}sum += (long)length*((long)length+1)/2;printf("%ld",(long)N*((long)N + 1)/2-sum);}