結果

問題 No.1338 Giant Class
ユーザー kumakumaaaaakumakumaaaaa
提出日時 2021-01-15 22:37:03
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 124 ms / 2,000 ms
コード長 824 bytes
コンパイル時間 1,641 ms
コンパイル使用メモリ 170,632 KB
実行使用メモリ 9,672 KB
最終ジャッジ日時 2023-08-17 17:56:41
合計ジャッジ時間 5,083 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 37 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 71 ms
7,412 KB
testcase_07 AC 110 ms
9,096 KB
testcase_08 AC 61 ms
7,000 KB
testcase_09 AC 53 ms
6,784 KB
testcase_10 AC 108 ms
9,508 KB
testcase_11 AC 9 ms
4,380 KB
testcase_12 AC 70 ms
6,652 KB
testcase_13 AC 61 ms
6,968 KB
testcase_14 AC 15 ms
4,376 KB
testcase_15 AC 22 ms
4,788 KB
testcase_16 AC 8 ms
4,376 KB
testcase_17 AC 61 ms
7,144 KB
testcase_18 AC 15 ms
4,380 KB
testcase_19 AC 27 ms
5,112 KB
testcase_20 AC 124 ms
9,672 KB
testcase_21 AC 120 ms
9,628 KB
testcase_22 AC 120 ms
9,660 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
// #include <atcoder/modint>
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define INF 2000000000000000000
#define ll long long
#define ld long double
#define pll pair<ll, ll>
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll H, W, Q;
  cin >> H >> W >> Q;
  ll ans = W * H;
  map<ll, ll> mp;
  for (ll i = 0; i < Q; ++i) {
    ll y, x;
    cin >> y >> x;
    y -= 1, x -= 1;
    if (mp.find(x) == mp.end()) {
      mp[x] = H;
    }
    ll before = mp[x];
    ll now = y;
    chmin(mp[x], y);
    ans -= max(0ll, before - now);
    cout << ans << "\n";
  }
}
0