結果
| 問題 | No.914 Omiyage |
| コンテスト | |
| ユーザー |
ate
|
| 提出日時 | 2019-10-25 23:13:42 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 1,493 bytes |
| コンパイル時間 | 2,013 ms |
| コンパイル使用メモリ | 198,576 KB |
| 最終ジャッジ日時 | 2025-01-08 01:45:00 |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 18 |
コンパイルメッセージ
main.cpp:30:1: warning: ISO C++ forbids declaration of ‘main’ with no type [-Wreturn-type]
30 | main(){
| ^~~~
ソースコード
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<(n);++i)
using ll = long long;
constexpr ll INF = (1LL<<60);
constexpr ll MOD = (1e9+7);
template<class T>inline bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>inline bool chmin(T &a,const T &b){if(a>b){a=b;return 1;}return 0;}
inline void dump(){cout<<endl;}
template<class Head,class... Tail>inline void dump(Head&& head, Tail&&... tail){cout<<head<<", ";dump(forward<Tail>(tail)...);}
template<typename T>inline istream &operator>>(istream&input,vector<T>&v){for(auto &elemnt:v)input>>elemnt;return input;}
template<class T>vector<T> make_vector(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto make_vector(size_t a, Ts... ts){return vector<decltype(make_vector<T>(ts...))>(a, make_vector<T>(ts...));}
ll ans;
int n,m,k;
void dfs(ll t,int i,vector<vector<ll>>& a){
if(k-t<0)return;
if(i+1==n){
chmin(ans,k-t);
return;
}
for(int nx=m-1;nx>=0;--nx){
dfs(t+a[i+1][nx],i+1,a);
}
}
main(){
cin>>n>>m>>k;
auto a = make_vector<ll>(n,m);
cin>>a;
auto dp = make_vector<ll>(n+1,k*10+1);
rep(j,m)dp[1][a[0][j]]=1;
rep(i,n)rep(j,m){
for(ll l=0;l<=k;++l){
if(dp[i][l])dp[i+1][l+a[i][j]]=1;
}
}
//for(int i=0;i<20;++i)cout<<i<<" ";cout<<endl;
//for(int i=0;i<20;++i)cout<<dp[n][i]<<" ";cout<<endl;
for(int i=k;i>=0;--i){
if(dp[n][i]){
cout<<k-i<<endl;
return 0;
}
}
cout<<-1<<endl;
}
ate