結果
問題 |
No.78 クジ付きアイスバー
|
ユーザー |
|
提出日時 | 2014-11-26 22:14:35 |
言語 | Java (openjdk 23) |
結果 |
WA
|
実行時間 | - |
コード長 | 591 bytes |
コンパイル時間 | 2,238 ms |
コンパイル使用メモリ | 74,216 KB |
実行使用メモリ | 41,584 KB |
最終ジャッジ日時 | 2024-10-06 17:01:32 |
合計ジャッジ時間 | 7,386 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | WA * 2 RE * 2 |
other | WA * 1 RE * 34 |
ソースコード
import java.util.*; import static java.lang.Math.*; public class Main { public static void main(String[] args) { Scanner sc=new Scanner(System.in); int n=sc.nextInt(); int A[]=new int[10000]; int sum=0; for(int i=0;i<n;i++){ A[i]=sc.nextInt(); sum+=A[i]; } int w=(int)pow(sum,0.5); int end=w*2-2; int ans=0; for(int i=0;i<w;i++){ ans+=max(A[i]-(i+1),0); } for(int i=w;i<=end;i++){ ans+=max(0,A[i]-(end-i+1)); } for(int i=end+1;i<10000;i++){ ans+=A[i]; } System.out.println(ans); }}