結果
問題 | No.2306 [Cherry 5th Tune C] ウソツキタマシイ |
ユーザー |
|
提出日時 | 2023-05-19 23:03:36 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 50 ms / 2,000 ms |
コード長 | 1,045 bytes |
コンパイル時間 | 2,528 ms |
コンパイル使用メモリ | 212,900 KB |
最終ジャッジ日時 | 2025-02-13 03:05:30 |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 30 |
ソースコード
#pragma GCC optimize("Ofast") #include <bits/stdc++.h> using namespace std; typedef long long int ll; typedef unsigned long long int ull; mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count()); ll myRand(ll B) { return (ull)rng() % B; } inline double time() { return static_cast<long double>(chrono::duration_cast<chrono::nanoseconds>(chrono::steady_clock::now().time_since_epoch()).count()) * 1e-9; } void slv() { int n,m; cin >> n >> m; vector<ll> a(m); ll res = 0; for (int i = 0; i < m; ++i) { cin >> a[i]; res += a[i]*a[i]; } int q; cin >> q; while (q--) { int i; cin >> i; i--; ll x; cin >> x; int j; cin >> j; j--; res -= a[i]*a[i]; res -= a[j]*a[j]; a[i] -= x; a[j] += x; res += a[i]*a[i]; res += a[j]*a[j]; cout << res << "\n"; } } int main() { cin.tie(nullptr); ios::sync_with_stdio(false); // int q; cin >> q; // while (q--) { // slv(); // } slv(); }