Task: | Blocks |
Sender: | Feeniksi |
Submission time: | 2016-09-27 16:59:20 +0300 |
Language: | Java |
Status: | READY |
Result: | ACCEPTED |
test | verdict | time | |
---|---|---|---|
#1 | ACCEPTED | 0.10 s | details |
#2 | ACCEPTED | 0.09 s | details |
#3 | ACCEPTED | 0.09 s | details |
#4 | ACCEPTED | 0.11 s | details |
#5 | ACCEPTED | 0.09 s | details |
#6 | ACCEPTED | 0.12 s | details |
#7 | ACCEPTED | 0.11 s | details |
#8 | ACCEPTED | 0.09 s | details |
#9 | ACCEPTED | 0.11 s | details |
#10 | ACCEPTED | 0.11 s | details |
#11 | ACCEPTED | 0.13 s | details |
#12 | ACCEPTED | 0.11 s | details |
#13 | ACCEPTED | 0.10 s | details |
#14 | ACCEPTED | 0.10 s | details |
#15 | ACCEPTED | 0.11 s | details |
#16 | ACCEPTED | 0.11 s | details |
#17 | ACCEPTED | 0.10 s | details |
#18 | ACCEPTED | 0.11 s | details |
#19 | ACCEPTED | 0.12 s | details |
#20 | ACCEPTED | 0.10 s | details |
#21 | ACCEPTED | 0.15 s | details |
#22 | ACCEPTED | 0.11 s | details |
#23 | ACCEPTED | 0.13 s | details |
#24 | ACCEPTED | 0.11 s | details |
#25 | ACCEPTED | 0.12 s | details |
#26 | ACCEPTED | 0.12 s | details |
#27 | ACCEPTED | 0.13 s | details |
#28 | ACCEPTED | 0.12 s | details |
#29 | ACCEPTED | 0.12 s | details |
#30 | ACCEPTED | 0.11 s | details |
Code
import java.util.ArrayList; /* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ /** * * @author viljampa */ public class Kilpa41 { /** * @param args the command line arguments */ public static void main(String[] args) { IO io = new IO(); ArrayList<Long> lista = new ArrayList(); int maara = io.nextInt(); for (int i = 0; i < maara; i++) { lista.add(io.nextLong()); } // lista.add(5L); // lista.add(7L); // lista.add(4L); // lista.add(6L); // lista.add(3L); // lista.add(1L); // lista.add(2L); // lista.add(3L); // lista.add(4L); // lista.add(5L); ArrayList<Long> pinot = new ArrayList(); for (int i = 0; i < lista.size(); i++) { int kohta = -1; long pienin = 1000000000; for (int j = 0; j < pinot.size(); j++) { if (lista.get(i) < pinot.get(j)) { if (pinot.get(j) - lista.get(i) < pienin) { pienin = pinot.get(j) - lista.get(i); kohta = j; } } } if (kohta == -1) { pinot.add(lista.get(i)); } else { pinot.set(kohta, lista.get(i)); } } io.println(pinot.size()); // String a = io.next(); // Lukee seuraavan välein erotellun merkkijonon. // int b = io.nextInt(); // Lukee seuraavan välein erotellun int-kokonaisluvun. // long c = io.nextLong(); // Lukee seuraavan välein erotellun long-kokonaisluvun. // double d = io.nextDouble(); // Lukee seuraavan välein erotellun double-liukuluvun. // Toimii kuten System.out.println. // io.println("Annoit syötteenä " + a + " " + b + " " + c + " " + d); io.close(); // TÄYTYY KUTSUA LOPUKSI, muuten tuloste voi jäädä kirjoittamatta } }
Test details
Test 1
Verdict: ACCEPTED
input |
---|
5 1 2 3 4 5 |
correct output |
---|
5 |
user output |
---|
5 |
Test 2
Verdict: ACCEPTED
input |
---|
3 2000 1999 1998 |
correct output |
---|
1 |
user output |
---|
1 |
Test 3
Verdict: ACCEPTED
input |
---|
6 888947812 255632128 310470259 ... |
correct output |
---|
3 |
user output |
---|
3 |
Test 4
Verdict: ACCEPTED
input |
---|
4 617082542 842820809 770021951 ... |
correct output |
---|
3 |
user output |
---|
3 |
Test 5
Verdict: ACCEPTED
input |
---|
8 714278219 784227423 409319089 ... |
correct output |
---|
2 |
user output |
---|
2 |
Test 6
Verdict: ACCEPTED
input |
---|
4 323548620 170481297 889562264 ... |
correct output |
---|
2 |
user output |
---|
2 |
Test 7
Verdict: ACCEPTED
input |
---|
1 476683151 |
correct output |
---|
1 |
user output |
---|
1 |
Test 8
Verdict: ACCEPTED
input |
---|
2 629714376 581892911 |
correct output |
---|
1 |
user output |
---|
1 |
Test 9
Verdict: ACCEPTED
input |
---|
6 523198668 325464999 948349338 ... |
correct output |
---|
2 |
user output |
---|
2 |
Test 10
Verdict: ACCEPTED
input |
---|
6 822568264 254647499 434272192 ... |
correct output |
---|
4 |
user output |
---|
4 |
Test 11
Verdict: ACCEPTED
input |
---|
433 1 2 3 4 5 6 7 8 9 10 11 12 13 ... |
correct output |
---|
433 |
user output |
---|
433 |
Test 12
Verdict: ACCEPTED
input |
---|
554 2000 1999 1998 1997 1996 1995 ... |
correct output |
---|
1 |
user output |
---|
1 |
Test 13
Verdict: ACCEPTED
input |
---|
630 882563506 195731667 430976596 ... |
correct output |
---|
49 |
user output |
---|
49 |
Test 14
Verdict: ACCEPTED
input |
---|
335 488807609 178110205 512054465 ... |
correct output |
---|
33 |
user output |
---|
33 |
Test 15
Verdict: ACCEPTED
input |
---|
120 174580714 91110553 34218342 94... |
correct output |
---|
20 |
user output |
---|
20 |
Test 16
Verdict: ACCEPTED
input |
---|
593 34099449 759420722 786869557 3... |
correct output |
---|
41 |
user output |
---|
41 |
Test 17
Verdict: ACCEPTED
input |
---|
97 393681127 117745478 576906971 ... |
correct output |
---|
16 |
user output |
---|
16 |
Test 18
Verdict: ACCEPTED
input |
---|
780 596776372 178963013 27288301 3... |
correct output |
---|
56 |
user output |
---|
56 |
Test 19
Verdict: ACCEPTED
input |
---|
769 927650514 16537731 669979959 5... |
correct output |
---|
53 |
user output |
---|
53 |
Test 20
Verdict: ACCEPTED
input |
---|
253 939795028 916965543 553106661 ... |
correct output |
---|
26 |
user output |
---|
26 |
Test 21
Verdict: ACCEPTED
input |
---|
1000 1 2 3 4 5 6 7 8 9 10 11 12 13 ... |
correct output |
---|
1000 |
user output |
---|
1000 |
Test 22
Verdict: ACCEPTED
input |
---|
1000 2000 1999 1998 1997 1996 1995 ... |
correct output |
---|
1 |
user output |
---|
1 |
Test 23
Verdict: ACCEPTED
input |
---|
1000 645404707 986143091 145611946 ... |
correct output |
---|
58 |
user output |
---|
58 |
Test 24
Verdict: ACCEPTED
input |
---|
1000 341727972 757181419 834201886 ... |
correct output |
---|
56 |
user output |
---|
56 |
Test 25
Verdict: ACCEPTED
input |
---|
1000 140851913 102736547 916629519 ... |
correct output |
---|
55 |
user output |
---|
55 |
Test 26
Verdict: ACCEPTED
input |
---|
1000 32986064 260267921 970027433 9... |
correct output |
---|
64 |
user output |
---|
64 |
Test 27
Verdict: ACCEPTED
input |
---|
1000 164970760 259631575 668929944 ... |
correct output |
---|
54 |
user output |
---|
54 |
Test 28
Verdict: ACCEPTED
input |
---|
1000 259307867 630607450 309297823 ... |
correct output |
---|
56 |
user output |
---|
56 |
Test 29
Verdict: ACCEPTED
input |
---|
1000 543833880 613702937 41531951 2... |
correct output |
---|
58 |
user output |
---|
58 |
Test 30
Verdict: ACCEPTED
input |
---|
1000 652483687 571130341 552217195 ... |
correct output |
---|
59 |
user output |
---|
59 |