結果

問題 No.54 Happy Hallowe'en
ユーザー kotatsugame
提出日時 2021-01-10 06:39:44
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 18 ms / 5,000 ms
コード長 510 bytes
コンパイル時間 845 ms
コンパイル使用メモリ 79,520 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-11-20 08:18:42
合計ジャッジ時間 1,900 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 19
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:9:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    9 | main()
      | ^~~~

ソースコード

diff #

#include<iostream>
#include<algorithm>
#include<vector>
#include<bitset>
using namespace std;
int N;
using bit=bitset<20202>;
bit dp;
main()
{
	cin>>N;
	vector<pair<int,int> >A(N);
	for(int i=0;i<N;i++)
	{
		cin>>A[i].first>>A[i].second;
	}
	sort(A.begin(),A.end(),[](pair<int,int>a,pair<int,int>b)
	{
		return a.first+a.second<b.first+b.second;
	});
	dp[0]=1;
	for(pair<int,int>p:A)
	{
		int v=p.first,t=p.second;
		dp|=(dp<<20202-t>>20202-t)<<v;
	}
	int ans=20201;
	while(!dp[ans])ans--;
	cout<<ans<<endl;
}
0