結果
問題 | No.2956 Substitute with Average |
ユーザー |
|
提出日時 | 2024-12-24 15:06:23 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
MLE
|
実行時間 | - |
コード長 | 899 bytes |
コンパイル時間 | 5,477 ms |
コンパイル使用メモリ | 309,264 KB |
実行使用メモリ | 814,776 KB |
最終ジャッジ日時 | 2024-12-24 15:06:57 |
合計ジャッジ時間 | 29,271 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 7 MLE * 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;int b=mx/2;vc v(t,vc<int>(mx,0));vc x(t,vc<int>(mx,0));vc<int>vv(n); rep(i,n)cin>>vv[i],vv[i]--;rep(i,t)v[i][b]=1;rep(i,t)if(vv[0]!=i)x[i][b]=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]+b];if(a!=i)ans+=x[i][s[i]+b];v[i][s[i]+b]++;if(j+1<n&&vv[j+1]!=i)x[i][s[i]+b]++;}}ans++;cout<<ans;}