1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | program pro10(input,output); var n,i,j,t:integer; a: array[1..100000] of integer; begin readln(n); j:=0; for i:= 1 to n do read(a[i]); readln; for i := 2 to n do begin if ( (a[i-1]>0) and (a[i]<0) ) then begin j := j+1; t:= a[i-1]; a[i-1] := a[i]; a[i] := t; end; end; writeln(j); writeln(a[1]); writeln(a[n]); end. |
cHJvZ3JhbSBwcm8xMChpbnB1dCxvdXRwdXQpOwp2YXIgbixpLGosdDppbnRlZ2VyOwogICAgYTogYXJyYXlbMS4uMTAwMDAwXSBvZiBpbnRlZ2VyOwpiZWdpbgogcmVhZGxuKG4pOwogajo9MDsKIGZvciBpOj0gMSB0byBuIGRvCiAgcmVhZChhW2ldKTsKIHJlYWRsbjsKIGZvciBpIDo9IDIgdG8gbiBkbwogIGJlZ2luCiAgIGlmICggKGFbaS0xXT4wKSBhbmQgKGFbaV08MCkgKSB0aGVuCiAgICBiZWdpbgogICAgIGogOj0gaisxOwogICAgIHQ6PSBhW2ktMV07CiAgICAgYVtpLTFdIDo9IGFbaV07CiAgICAgYVtpXSA6PSB0OwogICAgZW5kOwogIGVuZDsKIHdyaXRlbG4oaik7CiB3cml0ZWxuKGFbMV0pOwogd3JpdGVsbihhW25dKTsKZW5kLg==
-
upload with new input
-
result: Success time: 0.01s memory: 448 kB returned value: 0
7 10 -9 -4 5 -2 3 8
3 -9 8
-
result: Success time: 0.02s memory: 448 kB returned value: 0
0 0 0



