結果
| 問題 |
No.2306 [Cherry 5th Tune C] ウソツキタマシイ
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-05-19 21:26:00 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 45 ms / 2,000 ms |
| コード長 | 604 bytes |
| コンパイル時間 | 1,703 ms |
| コンパイル使用メモリ | 169,080 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-12-18 02:14:57 |
| 合計ジャッジ時間 | 4,835 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 30 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
ll ans = 0, n, m;
cin >> n >> m;
vector<ll> cnt(m + 1);
for(int i = 0; i < m; i++){
cin >> cnt[i];
ans += cnt[i] * cnt[i];
}
int Q;
cin >> Q;
while(Q--){
ll c, k, d;
cin >> c >> k >> d;
c--, d--;
ans -= cnt[c] * cnt[c];
ans -= cnt[d] * cnt[d];
cnt[c] -= k;
cnt[d] += k;
ans += cnt[c] * cnt[c];
ans += cnt[d] * cnt[d];
cout << ans << '\n';
}
}