結果
問題 | No.1279 Array Battle |
ユーザー | yoshykai |
提出日時 | 2020-12-03 19:18:33 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 103 ms / 2,000 ms |
コード長 | 2,797 bytes |
コンパイル時間 | 3,321 ms |
コンパイル使用メモリ | 76,536 KB |
実行使用メモリ | 51,844 KB |
最終ジャッジ日時 | 2023-10-12 05:24:19 |
合計ジャッジ時間 | 5,958 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge15 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 48 ms
49,740 KB |
testcase_01 | AC | 48 ms
49,744 KB |
testcase_02 | AC | 50 ms
49,816 KB |
testcase_03 | AC | 49 ms
49,520 KB |
testcase_04 | AC | 49 ms
49,632 KB |
testcase_05 | AC | 47 ms
49,780 KB |
testcase_06 | AC | 49 ms
49,792 KB |
testcase_07 | AC | 48 ms
49,632 KB |
testcase_08 | AC | 49 ms
49,708 KB |
testcase_09 | AC | 48 ms
50,088 KB |
testcase_10 | AC | 49 ms
49,492 KB |
testcase_11 | AC | 50 ms
47,932 KB |
testcase_12 | AC | 54 ms
49,928 KB |
testcase_13 | AC | 64 ms
51,152 KB |
testcase_14 | AC | 63 ms
51,064 KB |
testcase_15 | AC | 90 ms
51,580 KB |
testcase_16 | AC | 90 ms
51,820 KB |
testcase_17 | AC | 91 ms
51,844 KB |
testcase_18 | AC | 103 ms
51,536 KB |
testcase_19 | AC | 90 ms
51,604 KB |
ソースコード
import java.util.*; import java.io.*; class Main{ static int count; public static void main(String args[]){ int n=readI(); int a[]=readIs(),b[]=readIs(); boolean flg[]=new boolean[n]; count=0; func(n,a,b,0,flg,0,0); pl(count+""); } public static int func(int n,int[] a,int[] b,int max,boolean[] flg,int now,int sum){ if(now==n){ if(max<sum){ max=sum;count=1; }else if(max==sum){ count++; } return max; } for(int i=0;i<n;i++){ if(!flg[i]){ flg[i]=true; int temp = Math.max(a[i]-b[now],0); sum+=temp; max = func(n,a,b,max,flg,now+1,sum); sum-=temp; flg[i]=false; } } return max; } static final BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); public static void pr(String str){ System.out.print(str); } public static void pl(String str){ System.out.println(str); } public static String read(){ try{ return ctos((char)br.read()); }catch(IOException e){ e.printStackTrace(); return ""; } } public static char readC(){ try{ return (char)br.read(); }catch(IOException e){ e.printStackTrace(); return (char)-1; } } public static String readL(){ try{ return br.readLine(); }catch(IOException e){ e.printStackTrace(); return ""; } } public static String readS(){ StringBuilder sb = new StringBuilder(); while(true){ try{ int k = br.read(); if(k==-1||(char)k==' '||(char)k=='\n'){break;} sb.append((char)k); }catch(IOException e){ e.printStackTrace(); } } return sb.toString(); } public static int readI(){ return stoi(readS()); } public static long readLong(){ return stol(readS()); } public static long stol(String s){ return Long.parseLong(s); } public static String[] readSs(){ return readL().split(" "); } public static int[] readIs(){ return stoi(readSs()); } public static int stoi(String s){ return Integer.parseInt(s); } public static int[] stoi(String s[]){ int a[]=new int[s.length]; for(int i=0;i<s.length;i++){ a[i]=stoi(s[i]); } return a; } public static String itos(int i){ return String.valueOf(i); } public static String[] itos(int[] a){ String s[]=new String[a.length]; for(int i=0;i<a.length;i++){ s[i]=itos(a[i]); } return s; } public static String ctos(char c){ return String.valueOf(c); } public static String cstos(char[] c){ return new String(c); } public static char stoc(String s){ return s.charAt(0); } public static char[] stocs(String s){ return s.toCharArray(); } }