結果

問題 No.2770 Coupon Optimization
ユーザー 沙耶花沙耶花
提出日時 2024-05-31 21:54:57
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 1,628 ms / 3,000 ms
コード長 1,046 bytes
コンパイル時間 4,321 ms
コンパイル使用メモリ 268,164 KB
実行使用メモリ 8,676 KB
最終ジャッジ日時 2024-05-31 21:55:19
合計ジャッジ時間 20,605 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 2 ms
6,944 KB
testcase_03 AC 503 ms
8,420 KB
testcase_04 AC 551 ms
8,676 KB
testcase_05 AC 38 ms
6,944 KB
testcase_06 AC 1,371 ms
7,840 KB
testcase_07 AC 569 ms
7,828 KB
testcase_08 AC 1,579 ms
7,988 KB
testcase_09 AC 178 ms
6,940 KB
testcase_10 AC 752 ms
6,940 KB
testcase_11 AC 486 ms
6,944 KB
testcase_12 AC 657 ms
6,940 KB
testcase_13 AC 661 ms
6,940 KB
testcase_14 AC 1,572 ms
7,976 KB
testcase_15 AC 1,548 ms
7,956 KB
testcase_16 AC 1,628 ms
7,972 KB
testcase_17 AC 1,572 ms
8,092 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace atcoder;
using mint = modint998244353;
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define Inf32 1000000001
#define Inf64 1000000000000000001


int main(){
	
	int N,M;
	cin>>N>>M;
	
	vector<int> a(N);
	rep(i,N)cin>>a[i];
	vector<int> cnt(100);
	rep(i,M){
		int b;
		cin>>b;
		cnt[b]++;
	}
	if(N>M)cnt[0] = N-M;
	if(N<M){
		rep(i,100){
			while(M!=N && cnt[i]>0){
				cnt[i]--;
				M--;
			}
		}
	}
	M = N;
	sort(a.begin(),a.end());
	vector<
	priority_queue<long long,vector<long long>,greater<long long>>> pq(100);
	rep(i,100){
		rep(j,cnt[i]){
			pq[i].push(0);
		}
	}
	long long sum = 0;
	long long toku = 0;
	rep(i,N){
		sum += a[i];
		toku += 99LL * a[i] / 100;
		pq[99].push(a[i]);
		for(int j=99;j>=1;j--){
			if(pq[j].size()>cnt[j]){
				long long t = pq[j].top();
				pq[j].pop();
				toku -= (long long)j * t / 100;
				toku += (long long)(j-1) * t / 100;
				pq[j-1].push(t);
			}
			
		}
		cout<<sum-toku<<endl;
	}
	return 0;
}
0