Submission #16129
ソースコード
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 | #include<stdio.h> #include<string.h> #include<algorithm> int as[6][101][101]; 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 h,o; scanf ( "%d %d" ,&h,&o); as[0][h][o]=0; for ( int p=1;p<6;p++){ char str[10]; int w,hate,m; scanf ( "%s %d %d %d" ,str,&w,&hate,&m); int old=p-1; int now=p; for ( int i=0;i<=h;i++){ for ( int j=0;j<=o;j++){ if (as[old][i][j]==-1) continue ; if (str[0]== 'h' ){ for ( int k=std::max(0,i-w);k<=i;k++){ int t=f(hate,w-(i-k)); if (t>m) continue ; int t2=as[now][k][j]; int t3=t+as[old][i][j]; if ((t2==-1)||(t2>t3)){ as[now][k][j]=t3; } } } else { for ( int k=std::max(0,j-w);k<=j;k++){ int t=f(hate,w-(j-k)); if (t>m) continue ; int t2=as[now][i][k]; int t3=t+as[old][i][j]; if ((t2==-1)||(t2>t3)){ as[now][i][k]=t3; } } } } } } int ans=-1; for ( int i=0;i<=h;i++){ for ( int j=0;j<=o;j++){ if (as[5][i][j]==-1) continue ; int t=as[5][i][j]; if (ans==-1||ans>t)ans=t; } } if (ans==-1){ printf ( "Hello!\n" ); } else { printf ( "%d\n" ,ans); } } |
ステータス
項目 | データ |
---|---|
問題 | 0015 - あふたぬーんてぃー |
ユーザー名 | sinapusu2002 |
投稿日時 | 2017-05-01 08:22:37 |
言語 | C++11 |
状態 | Accepted |
得点 | 30 |
ソースコード長 | 1240 Byte |
最大実行時間 | 22 ms |
最大メモリ使用量 | 748 KB |
セット
セット | 得点 | Cases | |
---|---|---|---|
1 | ALL | 30 / 30 | * |
テストケース
ファイル名 | 状態 | 実行時間 | メモリ使用量 | # |
---|---|---|---|---|
Alice_in1.txt | AC | 22 ms | 736 KB |
1
|
Alice_in2.txt | AC | 19 ms | 748 KB |
1
|
Alice_in3.txt | AC | 14 ms | 632 KB |
1
|
Alice_in4.txt | AC | 17 ms | 640 KB |
1
|
Alice_in5.txt | AC | 14 ms | 656 KB |
1
|