結果
| 問題 | No.78 クジ付きアイスバー |
| コンテスト | |
| ユーザー |
testestest
|
| 提出日時 | 2016-10-30 03:45:20 |
| 言語 | C90 (gcc 12.4.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 5,000 ms |
| コード長 | 487 bytes |
| 記録 | |
| コンパイル時間 | 262 ms |
| コンパイル使用メモリ | 29,384 KB |
| 最終ジャッジ日時 | 2026-02-23 22:46:25 |
|
ジャッジサーバーID (参考情報) |
judge5 / 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: In function ‘main’:
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:1:1: note: include ‘<stdio.h>’ or provide a declaration of ‘scanf’
+++ |+#include <stdio.h>
1 | char box[60];
main.c:22:16: warning: incompatible implicit declaration of built-in function ‘printf’ [-Wbuiltin-declaration-mismatch]
22 | if(k<n)printf("%d",hasuu(k,0));
| ^~~~~~
main.c:22:16: note: include ‘<stdio.h>’ or provide a declaration of ‘printf’
ソースコード
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