結果

問題 No.2306 [Cherry 5th Tune C] ウソツキタマシイ
ユーザー KKT89KKT89
提出日時 2023-05-19 23:03:36
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 47 ms / 2,000 ms
コード長 1,045 bytes
コンパイル時間 2,758 ms
コンパイル使用メモリ 211,508 KB
実行使用メモリ 4,504 KB
最終ジャッジ日時 2023-08-23 01:03:09
合計ジャッジ時間 6,259 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 29 ms
4,380 KB
testcase_08 AC 9 ms
4,380 KB
testcase_09 AC 20 ms
4,376 KB
testcase_10 AC 17 ms
4,384 KB
testcase_11 AC 22 ms
4,380 KB
testcase_12 AC 29 ms
4,376 KB
testcase_13 AC 21 ms
4,380 KB
testcase_14 AC 17 ms
4,380 KB
testcase_15 AC 36 ms
4,380 KB
testcase_16 AC 37 ms
4,376 KB
testcase_17 AC 47 ms
4,376 KB
testcase_18 AC 46 ms
4,380 KB
testcase_19 AC 46 ms
4,384 KB
testcase_20 AC 46 ms
4,376 KB
testcase_21 AC 47 ms
4,380 KB
testcase_22 AC 47 ms
4,376 KB
testcase_23 AC 45 ms
4,380 KB
testcase_24 AC 45 ms
4,384 KB
testcase_25 AC 46 ms
4,380 KB
testcase_26 AC 47 ms
4,376 KB
testcase_27 AC 37 ms
4,376 KB
testcase_28 AC 41 ms
4,380 KB
testcase_29 AC 34 ms
4,504 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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();
}
0