Submission #2241635


Source Code Expand

//set many funcs template
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<stdbool.h>
#include<time.h>
#define inf 1072114514
#define llinf 4154118101919364364
#define mod 1000000007
#define pi 3.1415926535897932384

int max(int a,int b){if(a>b){return a;}return b;}
int min(int a,int b){if(a<b){return a;}return b;}
int zt(int a,int b){return max(a,b)-min(a,b);}
int round(int a,int b){if((a%b)*2 >= b){return (a/b)+1;}return a/b;}
int ceil(int a,int b){if(a%b==0){return a/b;}return (a/b)+1;}
int gcd(int a,int b){int c;while(b!=0){c=a%b;a=b;b=c;}return a;}
int lcm(int a,int b){int c=gcd(a,b);a/=c;return a*b;}
int nCr(int a,int b){int i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
int fact(int a){int i,r=1;for(i=1;i<=a;i++){r*=i;}return r;}
int pow(int a,int b){int i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}
long long llmax(long long a,long long b){if(a>b){return a;}return b;}
long long llmin(long long a,long long b){if(a<b){return a;}return b;}
long long llzt(long long a,long long b){return llmax(a,b)-llmin(a,b);}
long long llround(long long a,long long b){if((a%b)*2 >= b){return (a/b)+1;}return a/b;}
long long llceil(long long a,long long b){if(a%b==0){return a/b;}return (a/b)+1;}
long long llgcd(long long a,long long b){long long c;while(b!=0){c=a%b;a=b;b=c;}return a;}
long long lllcm(long long a,long long b){long long c=llgcd(a,b);a/=c;return a*b;}
long long llnCr(long long a,long long b){long long i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
long long llfact(long long a){long long i,r=1;for(i=1;i<=a;i++){r*=i;}return r;}
long long llpow(long long a,long long b){long long i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}
double dbmax(double a,double b){if(a>b){return a;}return b;}
double dbmin(double a,double b){if(a<b){return a;}return b;}
double dbzt(double a,double b){return dbmax(a,b)-dbmin(a,b);}
int sortfncsj(const void *a,const void *b){if(*(int *)a>*(int *)b){return 1;}if(*(int *)a==*(int *)b){return 0;}return -1;}
int sortfnckj(const void *a,const void *b){if(*(int *)a<*(int *)b){return 1;}if(*(int *)a==*(int *)b){return 0;}return -1;}
int llsortfncsj(const void *a,const void *b){if(*(long long *)a>*(long long *)b){return 1;}if(*(long long *)a==*(long long *)b){return 0;}return -1;}
int llsortfnckj(const void *a,const void *b){if(*(long long *)a<*(long long *)b){return 1;}if(*(long long *)a==*(long long *)b){return 0;}return -1;}
int dbsortfncsj(const void *a,const void *b){if(*(double *)a>*(double *)b){return 1;}if(*(double *)a==*(double *)b){return 0;}return -1;}
int dbsortfnckj(const void *a,const void *b){if(*(double *)a<*(double *)b){return 1;}if(*(double *)a==*(double *)b){return 0;}return -1;}
int strsortfncsj(const void *a,const void *b){return strcmp((char *)a,(char *)b);}
int strsortfnckj(const void *a,const void *b){return strcmp((char *)b,(char *)a);}

typedef struct{
long long hv;
long long pv;
}data;

int sortfnc(const void *a,const void *b){
long long ah,ap,bh,bp;
ah=((data*)a)->hv;
ap=((data*)a)->pv;
bh=((data*)b)->hv;
bp=((data*)b)->pv;
if(ah+ap<bh+bp){return -1;}
if(ah+ap>bh+bp){return 1;}
if(ap<bp){return -1;}
if(ap>bp){return 1;}
return 0;
}

int main(void){
    long long i,j,n,m,k,a,b,c,w,r=0,l,t,nz=0;
    double d;
    char s[262144];
    data dat[8192];
    long long dp[5005][5005]={0};
    scanf("%lld",&n);
    //l=strlen(s);
    for(i=0;i<n;i++){scanf("%lld%lld",&a,&b);
        dat[i].hv=a;
        dat[i].pv=b;
    }
    qsort(dat,n,sizeof(data),sortfnc);
    for(i=0;i<5005;i++){
        for(j=0;j<5005;j++){dp[i][j]=llinf;}
    }dp[0][0]=0;
    for(i=1;i<=n;i++){
        for(j=i+1;j>=1;j--){
            if(dp[i-1][j-1] > dat[i-1].hv){dp[i][j]=dp[i-1][j];}
            else{dp[i][j]=llmin(dp[i-1][j],dp[i-1][j-1]+dat[i-1].pv);}
        }
    }
    for(i=0;i<=n;i++){if(dp[n][i]!=llinf){r=i;}}
    printf("%lld\n",r);
    return 0;
}

Submission Info

Submission Time
Task D - Zabuton
User physics0523
Language C (GCC 5.4.1)
Score 700
Code Size 3933 Byte
Status AC
Exec Time 90 ms
Memory 196092 KB

Compile Error

./Main.c:15:5: warning: conflicting types for built-in function ‘round’
 int round(int a,int b){if((a%b)*2 >= b){return (a/b)+1;}return a/b;}
     ^
./Main.c:16:5: warning: conflicting types for built-in function ‘ceil’
 int ceil(int a,int b){if(a%b==0){return a/b;}return (a/b)+1;}
     ^
./Main.c:21:5: warning: conflicting types for built-in function ‘pow’
 int pow(int a,int b){int i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}
     ^
./Main.c:25:11: warning: conflicting types for built-in function ‘llround’
 long long llround(long long a,long long b){if((a%b)*2 >= b){return (a/b)+1;}return a/b;}
           ^
./Main.c: In function ‘main’:
./Main.c:68:5: warning: ignoring return value of ‘scanf’, declared with attribute warn_unused_result [-Wunused-result]
     scanf("%lld",&n);
     ^
./Main.c:70:22: warning: ignoring return value of ‘scanf’, declared with attribute warn_unused_result [-Wunused-result]
     for(i=0;i<n;i++){scanf("%lld%lld",&a,&b);
                      ^

Judge Result

Set Name sample All
Score / Max Score 0 / 0 700 / 700
Status
AC × 3
AC × 46
Set Name Test Cases
sample sample-01.txt, sample-02.txt, sample-03.txt
All sample-01.txt, sample-02.txt, sample-03.txt, 01-01.txt, 01-02.txt, 01-03.txt, 01-04.txt, 01-05.txt, 01-06.txt, 01-07.txt, 01-08.txt, 01-09.txt, 01-10.txt, 01-11.txt, 01-12.txt, 01-13.txt, 01-14.txt, 01-15.txt, 01-16.txt, 01-17.txt, 01-18.txt, 01-19.txt, 01-20.txt, 01-21.txt, 01-22.txt, 01-23.txt, 01-24.txt, 01-25.txt, 01-26.txt, 01-27.txt, 01-28.txt, 01-29.txt, 01-30.txt, 01-31.txt, 01-32.txt, 01-33.txt, 01-34.txt, 01-35.txt, 01-36.txt, 01-37.txt, 01-38.txt, 01-39.txt, 01-40.txt, sample-01.txt, sample-02.txt, sample-03.txt
Case Name Status Exec Time Memory
01-01.txt AC 70 ms 195840 KB
01-02.txt AC 71 ms 195840 KB
01-03.txt AC 72 ms 195964 KB
01-04.txt AC 75 ms 195968 KB
01-05.txt AC 86 ms 196092 KB
01-06.txt AC 86 ms 196092 KB
01-07.txt AC 87 ms 196092 KB
01-08.txt AC 86 ms 196092 KB
01-09.txt AC 86 ms 196092 KB
01-10.txt AC 70 ms 195840 KB
01-11.txt AC 71 ms 195840 KB
01-12.txt AC 77 ms 195968 KB
01-13.txt AC 87 ms 195968 KB
01-14.txt AC 87 ms 196092 KB
01-15.txt AC 87 ms 196092 KB
01-16.txt AC 87 ms 196092 KB
01-17.txt AC 87 ms 196092 KB
01-18.txt AC 87 ms 196092 KB
01-19.txt AC 71 ms 195840 KB
01-20.txt AC 72 ms 195964 KB
01-21.txt AC 80 ms 195968 KB
01-22.txt AC 89 ms 196092 KB
01-23.txt AC 88 ms 196092 KB
01-24.txt AC 88 ms 196092 KB
01-25.txt AC 88 ms 196092 KB
01-26.txt AC 89 ms 196092 KB
01-27.txt AC 88 ms 196092 KB
01-28.txt AC 86 ms 196092 KB
01-29.txt AC 85 ms 195968 KB
01-30.txt AC 86 ms 196092 KB
01-31.txt AC 86 ms 196092 KB
01-32.txt AC 86 ms 196092 KB
01-33.txt AC 86 ms 195968 KB
01-34.txt AC 86 ms 196092 KB
01-35.txt AC 89 ms 196092 KB
01-36.txt AC 89 ms 196092 KB
01-37.txt AC 89 ms 195968 KB
01-38.txt AC 89 ms 196092 KB
01-39.txt AC 90 ms 195968 KB
01-40.txt AC 86 ms 196092 KB
sample-01.txt AC 70 ms 195840 KB
sample-02.txt AC 70 ms 195840 KB
sample-03.txt AC 70 ms 195968 KB