結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 67 ms
4,860 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 52 ms
4,596 KB
testcase_07 AC 71 ms
4,892 KB
testcase_08 AC 48 ms
4,380 KB
testcase_09 AC 44 ms
4,380 KB
testcase_10 AC 79 ms
4,852 KB
testcase_11 AC 9 ms
4,380 KB
testcase_12 AC 55 ms
4,448 KB
testcase_13 AC 54 ms
4,376 KB
testcase_14 AC 15 ms
4,380 KB
testcase_15 AC 22 ms
4,380 KB
testcase_16 AC 8 ms
4,376 KB
testcase_17 AC 53 ms
4,380 KB
testcase_18 AC 16 ms
4,376 KB
testcase_19 AC 26 ms
4,376 KB
testcase_20 AC 93 ms
4,952 KB
testcase_21 AC 93 ms
5,128 KB
testcase_22 AC 93 ms
4,884 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() {
    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