結果

問題 No.851 テストケース
ユーザー 37zigen37zigen
提出日時 2020-03-17 02:00:30
言語 Java21
(openjdk 21)
結果
AC  
実行時間 147 ms / 3,153 ms
コード長 2,930 bytes
コンパイル時間 3,281 ms
コンパイル使用メモリ 75,512 KB
実行使用メモリ 55,980 KB
最終ジャッジ日時 2023-08-19 08:23:33
合計ジャッジ時間 7,863 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 145 ms
55,712 KB
testcase_01 AC 147 ms
55,684 KB
testcase_02 AC 129 ms
55,864 KB
testcase_03 AC 141 ms
55,724 KB
testcase_04 AC 142 ms
55,840 KB
testcase_05 AC 146 ms
55,772 KB
testcase_06 AC 132 ms
55,456 KB
testcase_07 AC 129 ms
55,600 KB
testcase_08 AC 129 ms
55,948 KB
testcase_09 AC 131 ms
55,480 KB
testcase_10 AC 132 ms
55,720 KB
testcase_11 AC 130 ms
55,404 KB
testcase_12 AC 126 ms
55,696 KB
testcase_13 AC 127 ms
55,720 KB
testcase_14 AC 127 ms
55,728 KB
testcase_15 AC 131 ms
55,684 KB
testcase_16 AC 131 ms
55,664 KB
testcase_17 AC 126 ms
55,980 KB
testcase_18 AC 126 ms
55,856 KB
testcase_19 AC 119 ms
55,376 KB
testcase_20 AC 119 ms
55,924 KB
testcase_21 AC 124 ms
55,740 KB
testcase_22 AC 128 ms
55,788 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;
import java.util.NoSuchElementException;
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		new Main().run();
	}
	
	void run() {
		Scanner sc=new Scanner(System.in);
		int N=Integer.parseInt(sc.nextLine());
		String str=sc.nextLine();
		if(str.contains(" ")) {
			System.out.println("\"assert\"");
		}else {
			long[] a=new long[N];
			a[0]=Long.valueOf(str);
			a[1]=sc.nextLong();
			a[2]=sc.nextLong();
			long[] b=new long[N*(N-1)/2];
			int p=0;
			for(int i=0;i<N;++i) {
				for(int j=i+1;j<N;++j) {
					b[p++]=a[i]+a[j];
				}
			}
			Arrays.sort(b);
			p=b.length-1;
			while(b[p]==b[b.length-1])--p;
			System.out.println(b[p]);
		}
	}
	
	void tr(Object...objects) {System.out.println(Arrays.deepToString(objects));}
}


class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}
0