結果
問題 |
No.2956 Substitute with Average
|
ユーザー |
![]() |
提出日時 | 2024-11-08 23:07:19 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 615 bytes |
コンパイル時間 | 1,395 ms |
コンパイル使用メモリ | 114,704 KB |
実行使用メモリ | 135,424 KB |
最終ジャッジ日時 | 2024-11-08 23:07:35 |
合計ジャッジ時間 | 12,903 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 8 WA * 17 |
ソースコード
#include <iostream> #include <vector> #include <map> #include <algorithm> using namespace std; int main() { int n; cin >> n; vector<int> a(n); for (int i = 0; i < n; ++i) cin >> a[i]; for (int i = 0; i < n; ++i) --a[i]; vector<map<int, int>> mp(30); vector<int> sum(n + 1); for (int i = 0; i < n; ++i) sum[i + 1] = sum[i] + a[i]; mp[a[0]][0] = 1; long long ans = (long long)(n + 1) * n / 2 + 1; for (int i = 1; i <= n; ++i) { int tmp = sum[i] - a[i - 1] * i; for (int j = 0; j < 30; ++j) ans -= mp[j][tmp]; if (i < n) mp[a[i]][sum[i] - i * a[i]]++; } cout << ans << endl; }