結果
| 問題 |
No.2956 Substitute with Average
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-12-24 15:08:39 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 895 bytes |
| コンパイル時間 | 6,461 ms |
| コンパイル使用メモリ | 314,448 KB |
| 実行使用メモリ | 510,436 KB |
| 最終ジャッジ日時 | 2024-12-24 15:09:57 |
| 合計ジャッジ時間 | 77,615 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 7 TLE * 18 |
ソースコード
#include<bits/stdc++.h>
using namespace std;
#include <atcoder/all>
using namespace atcoder;
using mint=modint998244353; //1000000007;
using ll=long long;
using pp=pair<int,int>;
#define sr string
#define vc vector
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define pb push_back
#define all(v) v.begin(),v.end()
#define pque priority_queue
#define bpc(a) __builtin_popcount(a)
int main(){
int n;cin>>n;
ll ans=(ll)n*(n+1)/2;
int t=30;
int mx=2*n*t+10;
vc<unordered_map<int,int>>v(t);
vc<unordered_map<int,int>>x(t);
vc<int>vv(n); rep(i,n)cin>>vv[i],vv[i]--;
rep(i,t)v[i][0]=1;
rep(i,t)if(vv[0]!=i)x[i][0]=1;
vc<int>s(t,0);
rep(j,n){
int a=vv[j];
rep(i,t){
s[i]+=a-i;
ans-=v[i][s[i]];
if(a!=i)ans+=x[i][s[i]];
v[i][s[i]]++;
if(j+1<n&&vv[j+1]!=i)x[i][s[i]]++;
}
}
ans++;
cout<<ans;
}