提出 #43137838


ソースコード 拡げる

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pi;
int n,m;
ll P[200005];
ll L[200005],D[200005];
int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	cin>>n>>m;
	for(int i=1; i<=n; i++) cin>>P[i];
	sort(P+1,P+n+1);
	
	for(int i=1; i<=m; i++) cin>>L[i];
	for(int i=1; i<=m; i++) cin>>D[i];
	
	priority_queue<pi,vector<pi>,greater<pi>>pq;
	for(int i=1; i<=m; i++) pq.push({L[i],D[i]});
	ll ans = 0;
	multiset<ll>st;
	for(int i=1; i<=n; i++){
		while(pq.size() && pq.top().first <= P[i]){
			st.insert(pq.top().second);
			pq.pop();
		}
		if(st.size()){
			P[i]-=*st.rbegin();
			st.erase(prev(st.end()));
		}
		ans+=P[i];
	}
	cout<<ans;
}

提出情報

提出日時
問題 F - Vouchers
ユーザ belphegor
言語 C++ (GCC 9.2.1)
得点 500
コード長 719 Byte
結果 AC
実行時間 126 ms
メモリ 19572 KiB

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 500 / 500
結果
AC × 2
AC × 19
セット名 テストケース
Sample 00_sample_01.txt, 00_sample_02.txt
All 00_sample_01.txt, 00_sample_02.txt, 01_random_01.txt, 01_random_02.txt, 01_random_03.txt, 01_random_04.txt, 01_random_05.txt, 01_random_06.txt, 01_random_07.txt, 01_random_08.txt, 01_random_09.txt, 01_random_10.txt, 01_random_11.txt, 01_random_12.txt, 01_random_13.txt, 01_random_14.txt, 01_random_15.txt, 02_handmade_01.txt, 02_handmade_02.txt
ケース名 結果 実行時間 メモリ
00_sample_01.txt AC 1 ms 3536 KiB
00_sample_02.txt AC 2 ms 3536 KiB
01_random_01.txt AC 2 ms 3528 KiB
01_random_02.txt AC 31 ms 4804 KiB
01_random_03.txt AC 57 ms 7384 KiB
01_random_04.txt AC 32 ms 5100 KiB
01_random_05.txt AC 40 ms 5420 KiB
01_random_06.txt AC 117 ms 11968 KiB
01_random_07.txt AC 117 ms 11976 KiB
01_random_08.txt AC 121 ms 12044 KiB
01_random_09.txt AC 116 ms 11936 KiB
01_random_10.txt AC 117 ms 11868 KiB
01_random_11.txt AC 118 ms 11980 KiB
01_random_12.txt AC 117 ms 11972 KiB
01_random_13.txt AC 117 ms 11976 KiB
01_random_14.txt AC 119 ms 12012 KiB
01_random_15.txt AC 116 ms 11936 KiB
02_handmade_01.txt AC 126 ms 19572 KiB
02_handmade_02.txt AC 72 ms 8396 KiB