Task: | Kyselyt |
Sender: | TapaniS |
Submission time: | 2020-10-17 10:02:49 +0300 |
Language: | Java |
Status: | READY |
Result: | 12 |
group | verdict | score |
---|---|---|
#1 | ACCEPTED | 12 |
#2 | TIME LIMIT EXCEEDED | 0 |
#3 | TIME LIMIT EXCEEDED | 0 |
test | verdict | time | group | |
---|---|---|---|---|
#1 | ACCEPTED | 0.16 s | 1, 2, 3 | details |
#2 | TIME LIMIT EXCEEDED | -- | 2, 3 | details |
#3 | TIME LIMIT EXCEEDED | -- | 3 | details |
#4 | TIME LIMIT EXCEEDED | -- | 3 | details |
#5 | TIME LIMIT EXCEEDED | -- | 3 | details |
Code
import java.util.*;public class kyselyt {public static void main(String[] args) {Scanner input = new Scanner(System.in);int n = input.nextInt();int q = input.nextInt();int[] elem = new int[n];int[] Istart = new int[q];int[] Iend = new int[q];int[] ans = new int[q];int[] modTbl = new int[n];for (int i = 0; i < n; i++) {elem[i] = input.nextInt();}for (int i = 0; i < q; i++) {Istart[i] = input.nextInt();Iend[i] = input.nextInt();}for (int i = 0; i < q; i++) {int sum1 = 0;int sum2 = 0;int val1 = 0;for (int k = (Istart[i]-1); k < Iend[i]; k++) {val1 = Math.max(elem[k], val1);sum1 += elem[k];sum2 += val1;}ans[i] = sum2 - sum1;}for (int i = 0; i < q; i++) {System.out.println(ans[i]);}input.close();}}
Test details
Test 1
Group: 1, 2, 3
Verdict: ACCEPTED
input |
---|
100 100 70 8 72 88 42 78 85 41 23 36 6... |
correct output |
---|
99 0 922 2579 1892 ... |
user output |
---|
99 0 922 2579 1892 ... Truncated |
Test 2
Group: 2, 3
Verdict: TIME LIMIT EXCEEDED
input |
---|
200000 200000 98 99 29 92 29 81 100 52 89 80... |
correct output |
---|
1497732 2810356 9532632 6655773 5403513 ... |
user output |
---|
(empty) |
Test 3
Group: 3
Verdict: TIME LIMIT EXCEEDED
input |
---|
200000 200000 818377786 934884634 816080381 ... |
correct output |
---|
86877225712611 94684086875470 92703793485296 38149694892093 61948503092286 ... |
user output |
---|
(empty) |
Test 4
Group: 3
Verdict: TIME LIMIT EXCEEDED
input |
---|
200000 200000 1 2 3 4 5 6 7 8 9 10 11 12 13 ... |
correct output |
---|
0 0 0 0 0 ... |
user output |
---|
(empty) |
Test 5
Group: 3
Verdict: TIME LIMIT EXCEEDED
input |
---|
200000 200000 200000 199999 199998 199997 19... |
correct output |
---|
15920862903 3193483321 18874982071 4846348926 3970697055 ... |
user output |
---|
(empty) |