이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
// Telebe of adicto yani AzeTurk810
/*
Author: AzeTurk810
Licance: open source(only authors name must be in code)
Begin Time:11/20/2024 20:48
Problem link: https://codeforces.com/problemset/problem/1543/D1
*/
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <cmath>
using namespace std;
using ll= long long;
using ull=unsigned long long;
# define vint vector<int>
//# define endl '\n'
# define range(a,b,c) for(int i=a;i<b;i+=c)
# define arange(a,b,c) for(int i=a;i>b;i-=c)
# define bend(x) (x).begin(),(x).end()
# define pb push_back
# define fori(x) for(int i=0;i<x;i++)
# define forj(y) for(int j=0;j<y;j++)
# define forn(x,c) for(int i=0;i<n;i+=c)
# define ff first
# define ss second
# define INF 1e9 + 7
# define printfprs(v) for(int alma = 0;alma<(v).size();alma++){cout<<(v)[alma].ff<< ' '<<(v)[alma].ss<<endl;};
# define int long long
int temp;
const int MAXN = 50005;
int t[MAXN *4];
void build(int a[],int v,int tl,int tr)
{
if(tl == tr)
{
t[v] = tl;
}
else
{
int tm = (tl + tr) / 2;
build(a, 2*v, tl, tm);
build(a, 2*v + 1, tm + 1, tr);
t[v] = max(t[v*2], t[v*2 + 1]);
}
}
int find(int a[],int v,int tl,int tr,int l,int r)
{
if(l>r)return -INF;
if(l==tl && r == tr)return t[v];
int tm = (tl + tr ) /2;
return max(find(a,v*2,tl,tm,l,min(tm,r)),find(a,v*2+1,tm + 1,tr,max(tm + 1,l),r));
}
signed main()
{
// ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
int n,k,m;
cin>>n>>m;
vector<int>dp(m + 2,0),v;
dp[0] = 1;
for(int i=0;i<n;i++)
{
cin>>k;
if(k<=m)
v.pb(k);
}
n = v.size();
for(int j=0;j<n;j++)
{
for(int i=0;i<=m;i++)
{
if(v[j] <=i)
{
dp[i]+=dp[i-v[j]];
}
}
}
cout<<dp[m]+1<<endl;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |