結果
問題 | No.2956 Substitute with Average |
ユーザー |
![]() |
提出日時 | 2024-11-08 21:44:35 |
言語 | C++17(gcc12) (gcc 12.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 1,210 ms / 3,000 ms |
コード長 | 758 bytes |
コンパイル時間 | 4,199 ms |
コンパイル使用メモリ | 267,468 KB |
実行使用メモリ | 10,368 KB |
最終ジャッジ日時 | 2024-11-08 21:44:59 |
合計ジャッジ時間 | 20,437 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 25 |
ソースコード
#include <stdio.h>#include <atcoder/all>#include <bits/stdc++.h>using namespace std;using namespace atcoder;using mint = modint998244353;#define rep(i,n) for (int i = 0; i < (n); ++i)#define Inf32 1000000001#define Inf64 1000000000000000000LLint main(){int n;cin>>n;vector<long long> a(n);rep(i,n){cin>>a[i];}long long ans = n;ans *= n+1;ans /= 2;ans++;for(int i=1;i<=30;i++){rep(j,2){map<int,long long> mp;if(a[0]!=i || j==0){mp[0]++;}long long cur = 0;rep(k,n){cur += a[k]-i;if(a[k]==i){ans -= mp[cur];}if(k!=n-1 && a[k+1]==i){if(j==0)mp[cur]++;}else mp[cur]++;}reverse(a.begin(),a.end());}}cout<<ans<<endl;return 0;}