?
# | Author | Problem | Lang | Verdict | Time | Memory | Sent | Judged | |
---|---|---|---|---|---|---|---|---|---|
131039333 |
Practice: Zahid_Hasan_Sahin |
1165E - 9 | Java 8 | Wrong answer on test 5 | 764 ms | 28572 KB | 2021-10-07 10:16:13 | 2021-10-07 10:16:13 |
import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; import java.util.Scanner; public class TwoArraysandSumofFunctions { public static void main(String args[]) { Scanner scan = new Scanner(System.in); int n = scan.nextInt(); ArrayList<Long> a = new ArrayList<Long>(); ArrayList<Long> b = new ArrayList<Long>(); for (int i = 0; i < n; i++) { long in = scan.nextInt(); a.add(in * ((i + 1) * (n - i))); } for (int i = 1; i <= n; i++) { long in = scan.nextInt(); b.add(in); } Collections.sort(a); Collections.sort(b, Collections.reverseOrder()); long res = 0; long mod = 998244353; for (int i = 0; i < n; i++) { res += ((a.get(i) % mod) * (b.get(i) % mod)) % mod; res %= mod; } System.out.println(res); } }
?
?
?
?