結果

問題 No.2422 regisys?
ユーザー startcppstartcpp
提出日時 2023-08-12 15:40:01
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,553 bytes
コンパイル時間 1,152 ms
コンパイル使用メモリ 81,360 KB
実行使用メモリ 4,512 KB
最終ジャッジ日時 2023-08-12 15:40:17
合計ジャッジ時間 10,743 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,384 KB
testcase_01 WA -
testcase_02 RE -
testcase_03 AC 2 ms
4,384 KB
testcase_04 RE -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 RE -
testcase_10 RE -
testcase_11 TLE -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
testcase_43 -- -
testcase_44 -- -
testcase_45 -- -
testcase_46 -- -
testcase_47 -- -
testcase_48 -- -
testcase_49 -- -
testcase_50 -- -
testcase_51 -- -
testcase_52 -- -
testcase_53 -- -
testcase_54 -- -
testcase_55 -- -
testcase_56 -- -
testcase_57 -- -
testcase_58 -- -
testcase_59 -- -
testcase_60 -- -
testcase_61 -- -
権限があれば一括ダウンロードができます

ソースコード

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(m);
	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, m) 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