提交记录 9629


用户 题目 状态 得分 用时 内存 语言 代码长度
lzoilxy noip18b. 【NOIP2018】货币系统 Accepted 100 5.402 ms 112 KB C++ 711 B
提交时间 评测时间
2019-06-20 22:24:10 2020-08-01 01:41:48
#include<algorithm>
#include<cstring>
#include<cstdio>
using namespace std;
int T,n,mx,sl,fh,ans,a[110],dp[25010];
int rd()
{
    sl=0;fh=1;
    char ch=getchar();
    while(ch<'0'||'9'<ch) {if(ch=='-') fh=-1; ch=getchar();}
    while('0'<=ch&&ch<='9') sl=sl*10+ch-'0',ch=getchar();
    return sl*fh;
}
void upd(int x) {for(int i=x;i<=mx;++i) dp[i]|=dp[i-x];}
int main()
{
    T=rd();
    while(T--)
    {
        n=rd();mx=0;ans=0;memset(dp,0,sizeof(dp));
        for(int i=1;i<=n;++i) a[i]=rd(),mx=max(mx,a[i]);
        sort(a+1,a+n+1);dp[0]=1;
        for(int i=1;i<=n;++i)
        {
            if(dp[a[i]]) continue;
            ans++;upd(a[i]);
        }
        printf("%d\n",ans);
    }
    return 0;
}

CompilationN/AN/ACompile OKScore: N/A

Testcase #160.65 us112 KBAcceptedScore: 5

Testcase #262.93 us112 KBAcceptedScore: 5

Testcase #363.16 us112 KBAcceptedScore: 5

Testcase #466.69 us112 KBAcceptedScore: 5

Testcase #565.81 us112 KBAcceptedScore: 5

Testcase #666.25 us112 KBAcceptedScore: 5

Testcase #768.12 us112 KBAcceptedScore: 5

Testcase #895.36 us112 KBAcceptedScore: 5

Testcase #971.46 us112 KBAcceptedScore: 5

Testcase #1072.41 us112 KBAcceptedScore: 5

Testcase #1166.12 us112 KBAcceptedScore: 5

Testcase #1266.13 us112 KBAcceptedScore: 5

Testcase #1365.08 us112 KBAcceptedScore: 5

Testcase #1474.53 us112 KBAcceptedScore: 5

Testcase #1572.48 us112 KBAcceptedScore: 5

Testcase #1673.06 us112 KBAcceptedScore: 5

Testcase #175.263 ms112 KBAcceptedScore: 5

Testcase #185.301 ms112 KBAcceptedScore: 5

Testcase #195.298 ms112 KBAcceptedScore: 5

Testcase #205.402 ms112 KBAcceptedScore: 5


Judge Duck Online | 评测鸭在线
Server Time: 2024-12-05 10:32:34 | Loaded in 1 ms | Server Status
个人娱乐项目,仅供学习交流使用 | 捐赠