結果

問題 No.1338 Giant Class
ユーザー merom686merom686
提出日時 2021-01-16 01:49:01
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 42 ms / 2,000 ms
コード長 937 bytes
コンパイル時間 889 ms
コンパイル使用メモリ 91,404 KB
実行使用メモリ 4,924 KB
最終ジャッジ日時 2023-08-17 20:15:42
合計ジャッジ時間 3,288 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 31 ms
4,588 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 24 ms
4,408 KB
testcase_07 AC 34 ms
4,888 KB
testcase_08 AC 23 ms
4,412 KB
testcase_09 AC 21 ms
4,376 KB
testcase_10 AC 38 ms
4,888 KB
testcase_11 AC 5 ms
4,376 KB
testcase_12 AC 27 ms
4,376 KB
testcase_13 AC 24 ms
4,376 KB
testcase_14 AC 7 ms
4,376 KB
testcase_15 AC 11 ms
4,376 KB
testcase_16 AC 5 ms
4,376 KB
testcase_17 AC 24 ms
4,380 KB
testcase_18 AC 8 ms
4,380 KB
testcase_19 AC 12 ms
4,380 KB
testcase_20 AC 41 ms
4,884 KB
testcase_21 AC 42 ms
4,892 KB
testcase_22 AC 42 ms
4,924 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cmath>
using namespace std;
using ll = long long;

struct P {
    bool operator<(const P &p) const {
        return x < p.x;
    }
    int x, i;
};

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);

    int h, w, q;
    cin >> h >> w >> q;

    ll r = (ll)h * w;

    vector<P> p(q);
    vector<int> x(q), y(q);
    for (int i = 0; i < q; i++) {
        cin >> y[i] >> p[i].x;
        p[i].i = i;
        y[i]--;
    }

    sort(p.begin(), p.end());
    int k = -1, t = -1;
    for (int i = 0; i < q; i++) {
        if (p[i].x != t) k++, t = p[i].x;
        x[p[i].i] = k;
    }
    k++;

    vector<int> b(k, h);
    for (int i = 0; i < q; i++) {
        if (y[i] < b[x[i]]) {
            r -= b[x[i]] - y[i];
            b[x[i]] = y[i];
        }

        cout << r << '\n';
    }

    return 0;
}
0