結果
| 問題 |
No.78 クジ付きアイスバー
|
| コンテスト | |
| ユーザー |
👑 testestest
|
| 提出日時 | 2016-10-30 03:45:20 |
| 言語 | C90 (gcc 12.3.0) |
| 結果 |
AC
|
| 実行時間 | 1 ms / 5,000 ms |
| コード長 | 487 bytes |
| コンパイル時間 | 765 ms |
| コンパイル使用メモリ | 20,224 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-11-24 23:30:36 |
| 合計ジャッジ時間 | 1,964 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 35 |
コンパイルメッセージ
main.c:2:1: warning: data definition has no type or storage class
2 | n,k,x,y;
| ^
main.c:2:1: warning: type defaults to ‘int’ in declaration of ‘n’ [-Wimplicit-int]
main.c:2:3: warning: type defaults to ‘int’ in declaration of ‘k’ [-Wimplicit-int]
2 | n,k,x,y;
| ^
main.c:2:5: warning: type defaults to ‘int’ in declaration of ‘x’ [-Wimplicit-int]
2 | n,k,x,y;
| ^
main.c:2:7: warning: type defaults to ‘int’ in declaration of ‘y’ [-Wimplicit-int]
2 | n,k,x,y;
| ^
main.c: In function ‘main’:
main.c:21:9: warning: implicit declaration of function ‘scanf’ [-Wimplicit-function-declaration]
21 | scanf("%d%d%s",&n,&k,box);
| ^~~~~
main.c:1:1: note: include ‘<stdio.h>’ or provide a declaration of ‘scanf’
+++ |+#include <stdio.h>
1 | char box[60];
main.c:21:9: warning: incompatible implicit declaration of built-in function ‘scanf’ [-Wbuiltin-declaration-mismatch]
21 | scanf("%d%d%s",&n,&k,box);
| ^~~~~
main.c:21:9: note: include ‘<stdio.h>’ or provide a declaration of ‘scanf’
main.c:22:16: warning: implicit declaration of function ‘printf’ [-Wimplicit-function-declaration]
22 | if(k<n)printf("%d",hasuu(k,0));
| ^~~~~~
main.c:22:16: note: include ‘<stdio.h>’ or provide a declaration of ‘printf’
main.c:22:16: warning: incompatible implicit declaration of built-in function ‘printf’ [-Wbuiltin-declaration-mismatch]
main.c:22:16: note: include ‘<stdio.h>’ or provide a declaration of ‘printf’
main.c:25:25: warning: incompatible implicit declaration of built-in function ‘printf’ [-Wbuiltin-declaration-mismatch]
25 | if(x<=y)printf("%d",x);
| ^~~~~~
main.c:25:25: note: include ‘<stdio.h>’ or provide a declaration of ‘printf’
main.c:26:22: warning: incompatible implicit declaration of built-in function ��
ソースコード
char box[60];
n,k,x,y;
void hakogai(){
int stock=0,cost=0,i;
for(i=0;i<n;i++){
if(stock>0)stock--;else cost++;
stock+=box[i]-'0';
}
x=cost;
y=stock;
}
int hasuu(int rest,int stock){
int cost=0,i;
for(i=0;i<rest;i++){
if(stock>0)stock--;else cost++;
stock+=box[i]-'0';
}
return cost;
}
int main(){
scanf("%d%d%s",&n,&k,box);
if(k<n)printf("%d",hasuu(k,0));
else {
hakogai();
if(x<=y)printf("%d",x);
else printf("%d",x+(x-y)*(k/n-1)+hasuu(k%n,y));
}
return 0;
}
testestest