結果
問題 | No.1583 Building Blocks |
ユーザー |
![]() |
提出日時 | 2021-07-02 23:09:35 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 5 ms / 2,000 ms |
コード長 | 586 bytes |
コンパイル時間 | 3,949 ms |
コンパイル使用メモリ | 230,928 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-09-14 02:49:54 |
合計ジャッジ時間 | 5,166 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 43 |
コンパイルメッセージ
main.cpp: In function 'int main()': main.cpp:22:9: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17' [-Wc++17-extensions] 22 | auto[s,w]=v[i]; | ^
ソースコード
#include<bits/stdc++.h> using namespace std; #include<atcoder/all> using namespace atcoder; using mint=modint1000000007; using ll=long long; using P=pair<ll,ll>; #define rep(i,N) for(int i=0;i<N;++i) constexpr ll inf=1LL<<60; ll N; P v[1001]; int main(){ cin>>N; rep(i,N){ cin>>v[i].second>>v[i].first; v[i].first+=v[i].second; } sort(v,v+N); vector<ll> dp(N+1,inf); dp[0]=0; rep(i,N){ auto[s,w]=v[i]; for(int j=N-1;j>=0;--j){ if(dp[j]+w<=s)dp[j+1]=min(dp[j+1],dp[j]+w); } } ll ans=0; while(ans<=N&&dp[ans]<inf)++ans; cout<<ans-1<<endl; }