結果

問題 No.91 赤、緑、青の石
ユーザー holeguma
提出日時 2015-08-17 22:48:59
言語 Java
(openjdk 23)
結果
AC  
実行時間 143 ms / 5,000 ms
コード長 785 bytes
コンパイル時間 2,110 ms
コンパイル使用メモリ 77,432 KB
実行使用メモリ 38,868 KB
最終ジャッジ日時 2024-06-24 06:50:59
合計ジャッジ時間 5,944 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 28
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.*;
import java.util.Arrays;

class Main{

static final PrintWriter out=new PrintWriter(System.out);

public static void main(String[] args) throws IOException{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
String line=br.readLine();
int[] st=new int[3];
int ans=0;
for(int i=0;i<3;i++) st[i]=Integer.parseInt(line.split(" ")[i]);
Arrays.sort(st);
if(st[0]==st[1]&&st[1]==st[2]) out.println(st[0]);
else if(st[0]==st[1]){
ans+=st[0];
st[2]-=st[0];
ans+=(int)st[2]/5;
out.println(ans);
}
else{
ans+=st[0];
st[1]-=st[0];
st[2]-=st[0];
st[0]=0;
if(3*st[1]<=st[2]){
ans+=st[1];
st[2]-=3*st[1];
ans+=(int)st[2]/5;
}
else{
while(st[2]>=3&&st[1]>0){
ans++;
st[1]--;
st[2]-=3;
Arrays.sort(st);
}
ans+=(int)st[2]/5;
}
out.println(ans);
}
out.flush();
}
}
0