結果
問題 |
No.5 数字のブロック
|
ユーザー |
|
提出日時 | 2016-06-21 07:11:44 |
言語 | Java (openjdk 23) |
結果 |
WA
|
実行時間 | - |
コード長 | 474 bytes |
コンパイル時間 | 2,348 ms |
コンパイル使用メモリ | 75,880 KB |
実行使用メモリ | 48,284 KB |
最終ジャッジ日時 | 2024-10-11 18:15:19 |
合計ジャッジ時間 | 9,866 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 2 WA * 32 |
ソースコード
import java.util.*; public class Main{ public static void main(String[] args){ Scanner sc = new Scanner(System.in); int L = sc.nextInt(); int N = sc.nextInt(); ArrayList<Integer> wide = new ArrayList<Integer>(); for( int i = 0 ; i < N ; i++ ){ wide.add(sc.nextInt()); } Collections.sort(wide); int w_sum = 0; for( int i = 0 ; i < N ; i++){ w_sum += wide.get(i); if( w_sum > L){ w_sum -= wide.get(i); } } System.out.println(w_sum); } }