結果
| 問題 | No.1338 Giant Class |
| コンテスト | |
| ユーザー |
merom686
|
| 提出日時 | 2021-01-16 01:49:01 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 45 ms / 2,000 ms |
| コード長 | 937 bytes |
| 記録 | |
| コンパイル時間 | 1,053 ms |
| コンパイル使用メモリ | 96,684 KB |
| 最終ジャッジ日時 | 2025-01-17 21:07:03 |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 21 |
ソースコード
#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;
}
merom686