Submission #1174576


Source Code Expand

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <stdlib.h>
#include <stdbool.h>
#define MOD 1000000007
void input_array(int how_data,int *data);
int get_random(int min, int max);
int factorial(int n);
int fibonacci(int n);
int qsort_09(const int *sys1 , const int *sys2);
int qsort_90(const int *sys1 , const int *sys2);
int sel_max(int a , int b);
int sel_min(int a , int b);
int can_DP_A(int how_data,int *data,int how_can,bool *can);
int main(void){
    int how_data;
    const int how_can=10001;
    scanf("%d",&how_data);
    int data[how_data];
    input_array(how_data,data);
    bool can[how_can];
    int ans=can_DP_A(how_data,data,how_can,can);
    printf("%d\n",ans);
    return 0;
    
    
}


//how_data個の配列data[]に標準入力
//input_array(how_data,data);
void input_array(int how_data,int *data){
    int loop;
    for(loop=0;loop<how_data;loop++){
        scanf("%d",&data[loop]);
    }
}

int get_random(int min, int max){   //指定の範囲から乱数を1つ返すやつ
    //srand((unsigned int)time(0));   //現在時刻で疑似乱数初期化
    rand();rand();rand();rand();    //乱数を空打ち
    return (rand()%(max+1-min))+min;
}


int factorial(int n){//n!のMOD10^9+7を返すやつ
    unsigned long long int ret=1;
    for(int i=1;i<=n;i++)ret=(ret*i)%1000000007;
    return (int)ret;
}

int qsort_09(const int *sys1 , const int *sys2){ //小さいのが上にくるやつ
    //qsort(data,how_data,sizeof(int),(int (*)(const void *,const void *))qsort_09);
    if(*sys1<*sys2){
        return -1;
    }else if(*sys1==*sys2){
        return 0;
    }else{
        return 1;
    }
}

int qsort_90(const int *sys1 , const int *sys2){ //大きいのが上にくるやつ
    //qsort(data,how_data,sizeof(int),(int (*)(const void *,const void *))qsort_90);
    if(*sys1<*sys2){
        return 1;
    }else if(*sys1==*sys2){
        return 0;
    }else{
        return -1;
    }
}

int fibonacci(int n){
    switch(n){
        case 0:return 0;
        case 1:return 1;
        default :return fibonacci(n-1)+fibonacci(n-2);
    }
}

int sel_max(int a,int b){
    if(a>b)return a;
    return b;
}

int sel_min(int a,int b){
    if(a>b)return b;
    return a;
}

int can_DP_A(int how_data,int *data,int how_can,bool *can){//Typical DP Contest A
    int loop1,loop2;
    int ret=0;
    for(loop1=0;loop1<how_can;loop1++){
        can[loop1]=0;
    }
    can[0]=1;
    for(loop1=0;loop1<how_data;loop1++){
        for(loop2=how_can-1;loop2>=0;loop2--){
            if(can[loop2]==1 && loop2+data[loop1]<how_can){
                can[loop2+data[loop1]]=1;
            }
        }
    }
    for(loop1=0;loop1<how_can;loop1++){
        if(can[loop1]==1){
            ret++;
        }
    }
    return ret;
    
}

Submission Info

Submission Time
Task A - コンテスト
User infer496
Language C (GCC 5.4.1)
Score 2
Code Size 2902 Byte
Status AC
Exec Time 1 ms
Memory 128 KB

Compile Error

./Main.c: In function ‘main’:
./Main.c:20:5: warning: ignoring return value of ‘scanf’, declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d",&how_data);
     ^
./Main.c: In function ‘input_array’:
./Main.c:37:9: warning: ignoring return value of ‘scanf’, declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d",&data[loop]);
         ^

Judge Result

Set Name All
Score / Max Score 2 / 2
Status
AC × 5
Set Name Test Cases
All 00, 01, 02, 90, 91
Case Name Status Exec Time Memory
00 AC 1 ms 128 KB
01 AC 1 ms 128 KB
02 AC 1 ms 128 KB
90 AC 1 ms 128 KB
91 AC 1 ms 128 KB