結果
| 問題 |
No.2956 Substitute with Average
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-11-08 22:33:47 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 571 bytes |
| コンパイル時間 | 2,191 ms |
| コンパイル使用メモリ | 204,736 KB |
| 最終ジャッジ日時 | 2025-02-25 02:53:53 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 8 WA * 17 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
int main(){
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int N; cin >> N;
vector<int> A(N);
for(auto &a : A) cin >> a;
vector<vector<int>> sepa(31);
for(int i=0; i<N; i++) sepa.at(A.at(i)).push_back(i);
long long answer = 1;
for(int i=1; i<=30; i++){
int pos = 0,zero = 0;
map<int,int> M;
for(auto &p : sepa.at(i)){
while(pos < p) M[zero]++,zero -= A.at(pos++)-i;
answer += p-M[zero];
}
}
cout << answer << endl;
}