結果

問題 No.1430 Coup de Coupon
ユーザー kotatsugamekotatsugame
提出日時 2021-03-14 14:12:41
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 55 ms / 2,000 ms
コード長 997 bytes
コンパイル時間 746 ms
コンパイル使用メモリ 77,888 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-06 01:04:48
合計ジャッジ時間 2,523 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 3 ms
4,376 KB
testcase_04 AC 4 ms
4,376 KB
testcase_05 AC 3 ms
4,376 KB
testcase_06 AC 55 ms
4,380 KB
testcase_07 AC 55 ms
4,376 KB
testcase_08 AC 5 ms
4,376 KB
testcase_09 AC 14 ms
4,380 KB
testcase_10 AC 22 ms
4,380 KB
testcase_11 AC 28 ms
4,376 KB
testcase_12 AC 35 ms
4,376 KB
testcase_13 AC 42 ms
4,376 KB
testcase_14 AC 46 ms
4,376 KB
testcase_15 AC 50 ms
4,376 KB
testcase_16 AC 54 ms
4,376 KB
testcase_17 AC 54 ms
4,380 KB
testcase_18 AC 41 ms
4,376 KB
testcase_19 AC 42 ms
4,376 KB
testcase_20 AC 19 ms
4,376 KB
testcase_21 AC 4 ms
4,376 KB
testcase_22 AC 1 ms
4,376 KB
testcase_23 AC 2 ms
4,376 KB
testcase_24 AC 2 ms
4,376 KB
testcase_25 AC 2 ms
4,376 KB
testcase_26 AC 4 ms
4,380 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:8:1: 警告: ISO C++ では型の無い ‘main’ の宣言を禁止しています [-Wreturn-type]
    8 | main()
      | ^~~~

ソースコード

diff #

#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int N,C;
int P[5050];
int dp[2][5050];
main()
{
	cin>>N>>C;
	for(int i=0;i<N;i++)cin>>P[i];
	sort(P,P+N);
	reverse(P,P+N);
	vector<int>A,B;
	for(int i=0;i<C;i++)
	{
		int t,x;cin>>t>>x;
		if(t==1)A.push_back(x);
		else B.push_back(x);
	}
	sort(A.begin(),A.end());
	reverse(A.begin(),A.end());
	sort(B.begin(),B.end());
	reverse(B.begin(),B.end());
	int now=0;
	for(int i=1;i<=A.size();i++)dp[now][i]=1e9;
	for(int i=0;i<N;i++)
	{
		int nxt=1-now;
		for(int j=0;j<=A.size();j++)dp[nxt][j]=1e9;
		for(int j=0;j<=A.size();j++)if(dp[now][j]<(int)1e9)
		{
			if(j<A.size())
			{
				dp[nxt][j+1]=min(dp[nxt][j+1],dp[now][j]+max(P[i]-A[j],0));
			}
			int k=i-j;
			if(k<B.size())
			{
				dp[nxt][j]=min(dp[nxt][j],dp[now][j]+P[i]/100*(100-B[k]));
			}
			else
			{
				dp[nxt][j]=min(dp[nxt][j],dp[now][j]+P[i]);
			}
		}
		now=nxt;
	}
	int ans=1e9;
	for(int j=0;j<=A.size();j++)ans=min(ans,dp[now][j]);
	cout<<ans<<endl;
}
0