結果

問題 No.1132 凸凹
ユーザー RISE70226821
提出日時 2020-08-04 09:29:38
言語 Java
(openjdk 23)
結果
AC  
実行時間 176 ms / 2,000 ms
コード長 848 bytes
コンパイル時間 2,266 ms
コンパイル使用メモリ 76,280 KB
実行使用メモリ 42,576 KB
最終ジャッジ日時 2024-09-14 07:02:05
合計ジャッジ時間 8,239 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 26
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;
import java.lang.*;
import java.io.*;

public class Main {
	public static void main (String[] args) throws java.lang.Exception
	{
		// your code goes here
		// 入力
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int d = sc.nextInt();
		int p = sc.nextInt();
		int q = sc.nextInt();
		
		// 算出
		int maxHeight = Integer.MIN_VALUE;
		int maxX = 0;
		int minHeight = Integer.MAX_VALUE;
		int minX = 0;
		
		for(int x = p; x <= q; x++){
			int height = a*x*x*x + b*x*x + c*x + d;
			if(maxHeight < height){
				maxHeight = height;
				maxX = x;
			}
			if(height < minHeight){
				minHeight = height;
				minX = x;
			}
		}
		
		// 出力
		System.out.println(maxHeight + " " + maxX + " " + minHeight + " " + minX);
	}
}
0