結果

問題 No.2422 regisys?
ユーザー startcppstartcpp
提出日時 2023-08-12 15:25:20
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,553 bytes
コンパイル時間 968 ms
コンパイル使用メモリ 81,796 KB
実行使用メモリ 11,056 KB
最終ジャッジ日時 2023-08-12 15:25:35
合計ジャッジ時間 8,393 ms
ジャッジサーバーID
(参考情報)
judge8 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,384 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,384 KB
testcase_04 AC 2 ms
4,384 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 2 ms
4,384 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 AC 1 ms
4,384 KB
testcase_13 AC 2 ms
4,380 KB
testcase_14 AC 2 ms
4,384 KB
testcase_15 AC 2 ms
4,384 KB
testcase_16 AC 2 ms
4,388 KB
testcase_17 AC 2 ms
4,380 KB
testcase_18 AC 2 ms
4,380 KB
testcase_19 WA -
testcase_20 AC 2 ms
4,380 KB
testcase_21 AC 2 ms
4,380 KB
testcase_22 AC 1 ms
4,380 KB
testcase_23 AC 1 ms
4,384 KB
testcase_24 AC 2 ms
4,380 KB
testcase_25 AC 1 ms
4,384 KB
testcase_26 AC 1 ms
4,380 KB
testcase_27 AC 2 ms
4,380 KB
testcase_28 AC 2 ms
4,380 KB
testcase_29 AC 1 ms
4,384 KB
testcase_30 AC 2 ms
4,380 KB
testcase_31 AC 107 ms
6,064 KB
testcase_32 WA -
testcase_33 AC 83 ms
6,128 KB
testcase_34 WA -
testcase_35 AC 102 ms
7,292 KB
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 AC 28 ms
4,384 KB
testcase_40 AC 54 ms
4,968 KB
testcase_41 WA -
testcase_42 AC 177 ms
9,676 KB
testcase_43 AC 83 ms
5,120 KB
testcase_44 AC 214 ms
9,676 KB
testcase_45 AC 160 ms
8,800 KB
testcase_46 AC 189 ms
9,464 KB
testcase_47 AC 120 ms
6,136 KB
testcase_48 AC 200 ms
11,056 KB
testcase_49 AC 159 ms
6,924 KB
testcase_50 AC 201 ms
10,608 KB
testcase_51 WA -
testcase_52 AC 85 ms
6,416 KB
testcase_53 AC 190 ms
9,016 KB
testcase_54 AC 253 ms
9,476 KB
testcase_55 AC 193 ms
8,780 KB
testcase_56 WA -
testcase_57 AC 286 ms
9,604 KB
testcase_58 AC 287 ms
9,552 KB
testcase_59 AC 286 ms
9,776 KB
testcase_60 AC 314 ms
9,672 KB
testcase_61 AC 1 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

//貧乏客から見ていく。一般人は買える商品の中でMMA部員にとって最も高価な商品を買う。逆も同様。プリキューで頑張る。
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#define rep(i, n) for(i = 0; i < n; i++)
using namespace std;
typedef pair<int, int> P;

int n, m;
int prices[2][200000];
vector<P> items[2];	//[0]: (a_i, 商品id), [1]: (b_i, 商品id)
vector<P> pa;	    //(財布, 客タイプ)
bool used[200000];
priority_queue<P> que[2];	//[0]: (MMA部員にとっての価格, 商品id), [1]: (一般人にとっての価格, 商品id)

int main() {
	int i;

	cin >> n >> m;
	items[0].resize(n); items[1].resize(n);
	pa.resize(n);
	rep(i, n) { cin >> prices[0][i]; items[0][i].first = prices[0][i]; items[0][i].second = i; }
	rep(i, n) { cin >> prices[1][i]; items[1][i].first = prices[1][i]; items[1][i].second = i; }
	rep(i, n) cin >> pa[i].second >> pa[i].first;
	sort(items[0].begin(), items[0].end());
	sort(items[1].begin(), items[1].end());
	sort(pa.begin(), pa.end());

	int cor[2] = {0};
	rep(i, n) {
		int t = pa[i].second;
		int wallet = pa[i].first;
		while (cor[t] < n && items[t][cor[t]].first <= wallet) {
			int item_id = items[t][cor[t]].second;
			que[t].push(P(prices[!t][item_id], item_id));
			cor[t]++;
		}
		while (!que[t].empty()) {
			P now = que[t].top(); que[t].pop();
			if (used[now.second] == false) {
				used[now.second] = true;
				break;
			}
		}
	}

	int ans = 0;
	rep(i, n) if (used[i]) ans++;
	
	cout << n - ans << endl;
	return 0;
}
0