結果
| 問題 | No.11 カードマッチ | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2016-03-09 17:08:14 | 
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) | 
| 結果 | 
                                WA
                                 
                            (最新) 
                                AC
                                 
                            (最初) | 
| 実行時間 | - | 
| コード長 | 878 bytes | 
| コンパイル時間 | 734 ms | 
| コンパイル使用メモリ | 76,904 KB | 
| 実行使用メモリ | 6,824 KB | 
| 最終ジャッジ日時 | 2024-10-09 20:09:24 | 
| 合計ジャッジ時間 | 1,389 ms | 
| ジャッジサーバーID (参考情報) | judge4 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 15 WA * 4 | 
ソースコード
#include <iostream>
#include <numeric>
#include <vector>
#include <unordered_map>
using namespace std;
int main() {
	long long w, h, n;
	cin >> w >> h >> n;
	unordered_map<long long, long long> group_types, group_nums;
	for (int i = 0; i < n; i++) {
		int type, num;
		cin >> type >> num;
		group_types[type] = h;
		if (group_nums.find(num) == group_nums.end())
			group_nums[num] = 0;
		else
			group_nums[num]++;
	}
	vector<long long> count_types;
	for (auto pair : group_types)
		count_types.push_back(pair.second);
	long long sum = 0;
	long long count_same_num = w - 1;
	int start = 0;
	for (auto pair : group_nums) {
		for (int i = start; i < count_types.size(); i++) {
			count_types[i]--;
		}
		sum += count_same_num - group_nums[pair.first];
		count_same_num--;
		start++;
	}
	cout << accumulate(count_types.begin(), count_types.end(), sum) << endl;
	return 0;
}
            
            
            
        