Submission #16130
ソースコード
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 | #include<stdio.h> #include<string.h> #include<algorithm> int as[11][1001]; int js[11]; int f( int hate, int n){ if (n==0){ return 0; } else { return 1<<(n+1+hate+1); } } int main(){ memset (as,-1, sizeof (as)); int m; scanf ( "%d" ,&m); for ( int i=0;i<m;i++){ scanf ( "%d" ,&js[i]); as[i][js[i]]=0; } for ( int p=1;p<6;p++){ int no,w,hate,maxA; scanf ( "%d %d %d %d" ,&no,&w,&hate,&maxA); no--; int bs[1001]; memset (bs,-1, sizeof (bs)); for ( int i=0;i<=js[no];i++){ if (as[no][i]==-1) continue ; for ( int j=std::max(0,i-w);j<=i;j++){ int t=f(hate,w-(i-j)); if (t>maxA) continue ; t=t+as[no][i]; int t2=bs[j]; if ((t2==-1)||(t2>t)){ bs[j]=t; } } } for ( int i=0;i<=js[no];i++){ as[no][i]=bs[i]; } } bool ok= true ; int ans=0; for ( int i=0;i<m;i++){ int t=-1; for ( int j=0;j<=js[i];j++){ if (as[i][j]==-1) continue ; if ((t==-1)||(t>as[i][j])){ t=as[i][j]; } } if (t==-1){ ok= false ; break ; } ans+=t; } if (ok== false ){ printf ( "Hello!\n" ); } else { printf ( "%d\n" ,ans); } } |
ステータス
項目 | データ |
---|---|
問題 | 0016 - ありすぬーんてぃー |
ユーザー名 | sinapusu2002 |
投稿日時 | 2017-05-01 08:48:37 |
言語 | C++11 |
状態 | Accepted |
得点 | 35 |
ソースコード長 | 1114 Byte |
最大実行時間 | 54 ms |
最大メモリ使用量 | 588 KB |
セット
セット | 得点 | Cases | |
---|---|---|---|
1 | ALL | 35 / 35 | * |
テストケース
ファイル名 | 状態 | 実行時間 | メモリ使用量 | # |
---|---|---|---|---|
Alice_in1.txt | AC | 38 ms | 480 KB |
1
|
Alice_in2.txt | AC | 28 ms | 432 KB |
1
|
Alice_in3.txt | AC | 35 ms | 508 KB |
1
|
Alice_in4.txt | AC | 19 ms | 588 KB |
1
|
Alice_in5.txt | AC | 54 ms | 532 KB |
1
|