結果
問題 | No.54 Happy Hallowe'en |
ユーザー |
![]() |
提出日時 | 2015-02-22 18:27:10 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 61 ms / 5,000 ms |
コード長 | 1,008 bytes |
コンパイル時間 | 837 ms |
コンパイル使用メモリ | 89,664 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-10-15 17:11:06 |
合計ジャッジ時間 | 1,831 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 19 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:29:9: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 29 | scanf("%d",&N); | ~~~~~^~~~~~~~~ main.cpp:32:12: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 32 | scanf("%d%d",&vec[i].first,&vec[i].second); | ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ソースコード
#include <cstdio> #include <cstdlib> #include <cmath> #include <climits> #include <cfloat> #include <map> #include <utility> #include <set> #include <iostream> #include <memory> #include <string> #include <vector> #include <algorithm> #include <functional> #include <sstream> #include <complex> #include <stack> #include <queue> #include <cstring> int mod = 1000000009; using namespace std; bool comp(const pair<int,int>& p1 ,const pair<int,int>& p2){ return p1.first+p1.second < p2.first+p2.second; } int main(){ int N; scanf("%d",&N); pair<int,int> vec[N]; for( int i=0;i<N;i++){ scanf("%d%d",&vec[i].first,&vec[i].second); } sort(vec,vec+N,comp); bool dp[20001]; memset(dp,false,sizeof(dp)); dp[0]=true; int ans = 0; for( int i = 0 ; i <N; i++ ){ for( int j = vec[i].second-1 ;j >=0 ; j-- ){ if(dp[j]){ dp[vec[i].first+j]=true; ans = max(ans,vec[i].first+j); } } } printf("%d\n",ans); return 0; }