結果

問題 No.11 カードマッチ
ユーザー tsukiotsukio
提出日時 2016-03-09 17:08:14
言語 C++11
(gcc 11.4.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 878 bytes
コンパイル時間 609 ms
コンパイル使用メモリ 77,044 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-18 02:28:25
合計ジャッジ時間 1,241 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 0 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 1 ms
5,376 KB
testcase_05 AC 1 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 0 ms
5,376 KB
testcase_10 AC 1 ms
5,376 KB
testcase_11 AC 2 ms
5,376 KB
testcase_12 AC 2 ms
5,376 KB
testcase_13 AC 1 ms
5,376 KB
testcase_14 AC 1 ms
5,376 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
}
0