結果
問題 | No.2208 Linear Function |
ユーザー | Asahi |
提出日時 | 2023-02-10 21:27:36 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 235 ms / 2,000 ms |
コード長 | 1,367 bytes |
コンパイル時間 | 3,059 ms |
コンパイル使用メモリ | 79,336 KB |
実行使用メモリ | 59,876 KB |
最終ジャッジ日時 | 2023-09-21 22:29:46 |
合計ジャッジ時間 | 4,412 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge15 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 121 ms
55,720 KB |
testcase_01 | AC | 218 ms
59,820 KB |
testcase_02 | AC | 228 ms
59,604 KB |
testcase_03 | AC | 235 ms
59,876 KB |
ソースコード
import java.util.*; import java.io.*; import java.math.*; import java.util.stream.Stream; public class Main{ static PrintWriter output; static Scanner sc; static void solve(){ int t = ni(); while(t-->0) { int l = ni(); int r = ni(); int a = ni(); int b = ni(); int max = -100000000; max = Math.max(max,calc(l,r,a,b)); output.println(max); } } static int calc(int l,int r,int a,int b) { int max = -100000000; for(int i=l ; i<=r ; i++) max = Math.max(max,a*i+b); return max; } public static void main(String[] args) throws IOException{ output = new PrintWriter(System.out); sc = new Scanner(System.in); solve(); output.flush(); } static int ni(){ return sc.nextInt();} static long nl(){ return sc.nextLong();} static String ns(){return sc.next();} static BigInteger bi(){return sc.nextBigInteger();} static BigDecimal bd(){return sc.nextBigDecimal();} static Map<Long,Integer> counter(long [] A) { HashMap<Long,Integer> count = new HashMap<>(); for(int i=0;i<A.length;i++) { if(!count.containsKey(A[i])) count.put(A[i],1); else count.put(A[i],count.get(A[i])+1); } return count; } }