結果
問題 | No.1606 Stuffed Animals Keeper |
ユーザー |
![]() |
提出日時 | 2023-09-01 05:11:03 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 854 bytes |
コンパイル時間 | 6,878 ms |
コンパイル使用メモリ | 332,368 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2025-01-03 06:16:24 |
合計ジャッジ時間 | 6,838 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 WA * 1 |
other | AC * 39 WA * 9 |
ソースコード
#include<bits/stdc++.h>using namespace std;#include <atcoder/all>using namespace atcoder;using mint=modint998244353; //1000000007;using ll=long long;using pp=pair<int,int>;#define sr string#define vc vector#define fi first#define se second#define rep(i,n) for(int i=0;i<(int)n;i++)#define pb push_back#define all(v) v.begin(),v.end()#define pque priority_queue#define bpc(a) __builtin_popcount(a)int main(){int n;cin>>n;vc<pp>v; v.pb({0,0});rep(i,n){int a;cin>>a;if(a==2)v.pb({0,0});if(a==0)v.back().fi++;if(a==1)v.back().se++;}int s=0,c=0;n=v.size();rep(i,n)s+=v[i].se+v[i].fi,c+=v[i].fi;vc<int>dp(c+1,1e8); dp[0]=0;rep(i,n){int t=v[i].fi+v[i].se;auto pre=dp;//rep(j,c+1)dp[j]=pre[j]+v[i].fi;rep(j,c+1)if(j+t<=c)dp[j+t]=min(dp[j+t],pre[j]+v[i].se);}cout<<dp[c];}