結果

問題 No.1338 Giant Class
ユーザー merom686
提出日時 2021-01-16 01:25:48
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 257 ms / 2,000 ms
コード長 615 bytes
コンパイル時間 709 ms
コンパイル使用メモリ 97,516 KB
最終ジャッジ日時 2025-01-17 21:06:39
ジャッジサーバーID
(参考情報)
judge3 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 21
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int main() {
    int h, w, q;
    cin >> h >> w >> q;

    ll r = (ll)h * w;
    map<int, int> mp;

    while (q--) {
        int y, x;
        cin >> y >> x;
        y--; x--;

        auto it = mp.insert({ x, y });
        if (it.second) {
            r -= h - y;
        } else if (int &t = it.first->second; y < t) {
            r -= t - y;
            t = y;
        }

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

    return 0;
}
0