General
 
 
# Author Problem Lang Verdict Time Memory Sent Judged  
3936374 Practice:
razimantv
234C - 22 GNU C++ Accepted 46 ms 11868 KB 2013-06-22 21:10:35 2013-06-22 21:10:35
 
 
→ Source
# include <cstdio>
# include <algorithm>

using namespace std;

int ar[1000000];
int nonneg[1000000],nonpos[1000000];

int main()
{
    FILE *f1,*f2;
    f1=fopen("input.txt","r");
    f2=fopen("output.txt","w");
    
    int N;
    fscanf(f1,"%d",&N);
    
    for(int i=0;i<N;i++)
        fscanf(f1,"%d",ar+i);
    
    nonneg[0]=(ar[0]>=0)?1:0;
    for(int i=1;i<N;i++)
        nonneg[i]=nonneg[i-1]+((ar[i]>=0)?1:0);
    
    nonpos[N-1]=(ar[N-1]<=0)?1:0;
    for(int i=N-2;i>=0;i--)
        nonpos[i]=nonpos[i+1]+((ar[i]<=0)?1:0);
    
    int best=N;
    for(int i=0;i<N-1;i++)
        best=min(best,nonneg[i]+nonpos[i+1]);
    
    fprintf(f2,"%d\n",best);
    
    fclose(f1);
    fclose(f2);
    return 0;
}
 
 
1
Time: 0 ms, memory: 11864 KB
Verdict: OK
Input
4
-1 1 -2 1
Output
1
Answer
1
Checker comment
ok answer is 1
 
 
2
Time: 0 ms, memory: 11864 KB
Verdict: OK
Input
5
0 -1 1 2 -5
Output
2
Answer
2
Checker comment
ok answer is 2
 
 
3
Time: 0 ms, memory: 11864 KB
Verdict: OK
Input
6
0 0 0 0 0 0
Output
6
Answer
6
Checker comment
ok answer is 6
 
 
4
Time: 0 ms, memory: 11864 KB
Verdict: OK
Input
6
-1 -2 -3 -4 5 6
Output
0
Answer
0
Checker comment
ok answer is 0
 
 
5
Time: 0 ms, memory: 11864 KB
Verdict: OK
Input
8
1 2 -1 0 10 2 12 13
Output
3
Answer
3
Checker comment
ok answer is 3
 
 
6
Time: 0 ms, memory: 11868 KB
Verdict: OK
Input
7
-1 -2 -3 3 -1 3 4
Output
1
Answer
1
Checker comment
ok answer is 1
 
 
7
Time: 0 ms, memory: 11868 KB
Verdict: OK
Input
2
3 -5
Output
2
Answer
2
Checker comment
ok answer is 2
 
 
8
Time: 0 ms, memory: 11868 KB
Verdict: OK
Input
50
4 -8 0 -1 -3 -9 0 -2 0 1 -1 0 7 -10 9 7 0 -10 5 0 1 -6 9 -9 3 -3 3 7 4 -8 -8 3 3 -1 0 2 -6 10 7 -1 -6 -3 -4 2 3 0 -4 0 7 -9
Output
26
Answer
26
Checker comment
ok answer is 26
 
 
9
Time: 0 ms, memory: 11868 KB
Verdict: OK
Input
90
52 -89 17 64 11 -61 92 51 42 -92 -14 -100 21 -88 73 -11 84 72 -80 -78 5 -70 -70 80 91 -89 87 -74 63 -79 -94 52 82 79 81 40 69 -15 33 -52 18 30 -39 99 84 -98 44 69 -75 0 60 -89 51 -92 83 73 16 -43 17 0 51 9 -53 86 86 -50 0 -80 3 0 86 0 -76 -45 0 -32 45...
Output
42
Answer
42
Checker comment
ok answer is 42
 
 
10
Time: 0 ms, memory: 11868 KB
Verdict: OK
Input
10
-19 -29 -21 -6 29 89 -74 -22 18 -13
Output
3
Answer
3
Checker comment
ok answer is 3
 
 
11
Time: 0 ms, memory: 11868 KB
Verdict: OK
Input
100
-782 365 -283 769 -58 224 1000 983 7 595 -963 -267 -934 -187 -609 693 -316 431 859 -753 865 -421 861 -728 -793 621 -311 414 -101 -196 120 84 633 -362 989 94 206 19 -949 -629 489 376 -391 165 50 22 -209 735 565 61 -321 -256 890 34 343 -326 984 -268 -6...
Output
40
Answer
40
Checker comment
ok answer is 40
 
 
12
Time: 15 ms, memory: 11868 KB
Verdict: OK
Input
500
9528 -24 1657 3701 5848 -1272 7730 1 -5709 9566 332 1269 9690 -3558 2747 6827 -8608 3832 -8529 -621 1106 -8161 4848 -54 -8755 -3498 -332 9201 -181 877 3013 7144 7691 7254 1136 486 -199 7055 6894 -7381 5820 -4755 -9091 -255 7613 6315 9279 -1600 1034 -...
Output
244
Answer
244
Checker comment
ok answer is 244
 
 
13
Time: 0 ms, memory: 11868 KB
Verdict: OK
Input
500
-10 0 0 0 -1 0 10 0 0 0 10 -5 7 1 -3 8 9 -9 9 -3 4 -1 10 0 10 0 0 -5 -4 0 9 3 0 7 0 -5 0 -4 -10 -7 0 0 0 8 7 10 7 10 -2 6 9 -8 0 1 6 1 0 -4 3 10 7 -10 10 0 -5 0 1 3 -6 -2 1 -4 6 -8 8 4 0 8 0 0 -5 0 -6 -8 8 4 -7 2 0 0 10 -10 -2 0 9 0 8 -5 10 -9 0 8 4 ...
Output
326
Answer
326
Checker comment
ok answer is 326
 
 
14
Time: 0 ms, memory: 11868 KB
Verdict: OK
Input
1000
228225344 991037620 -331297861 771240667 -799593559 235493773 863181279 41129079 454114592 965328065 0 -970993743 -361845918 932548861 937546211 368079328 -196455283 504889993 -419156883 140065858 -372830690 242608464 358625945 0 646970829 -19531798...
Output
549
Answer
549
Checker comment
ok answer is 549
 
 
15
Time: 0 ms, memory: 11868 KB
Verdict: OK
Input
1000
0 67292 -50436 37280 -70273 74643 73491 -41614 0 -9830 64392 -69574 89846 13976 19406 0 85046 0 -75598 13341 99442 47553 -23796 -38593 38020 -42590 31018 15448 -88328 94148 -40410 84661 -91735 93845 50863 0 -60332 -93652 0 -11755 0 0 41009 -95880 79...
Output
535
Answer
535
Checker comment
ok answer is 535
 
 
16
Time: 0 ms, memory: 11868 KB
Verdict: OK
Input
700
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...
Output
700
Answer
700
Checker comment
ok answer is 700
 
 
17
Time: 0 ms, memory: 11864 KB
Verdict: OK
Input
1000
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0...
Output
1000
Answer
1000
Checker comment
ok answer is 1000
 
 
18
Time: 0 ms, memory: 11864 KB
Verdict: OK
Input
300
287 236 32 -65 178 212 -158 74 73 279 197 296 203 141 -40 278 -38 99 142 0 253 209 -204 210 -70 -228 -238 -217 -35 35 -242 -37 232 -109 -98 273 -26 -57 252 -24 -80 8 17 236 97 -97 105 48 63 31 -43 77 -144 -45 198 -267 132 116 173 -100 -188 -263 -129 ...
Output
146
Answer
146
Checker comment
ok answer is 146
 
 
19
Time: 0 ms, memory: 11868 KB
Verdict: OK
Input
1000
90 29 -20 15 -78 42 42 67 -31 -85 -55 -10 79 -19 -80 28 24 77 -19 -90 -46 -4 35 73 57 -91 44 -68 -19 19 -92 -57 7 41 82 -68 -50 -49 -80 -90 89 -64 -78 2 40 42 84 90 11 -3 -75 82 -16 -17 -28 -90 -2 -88 -94 43 -42 100 70 -41 -45 -89 -93 -58 75 89 -56 ...
Output
479
Answer
479
Checker comment
ok answer is 479
 
 
20
Time: 0 ms, memory: 11868 KB
Verdict: OK
Input
1000
1699 -4116 34 -2602 7108 120 -161 4204 3948 -6830 0 -2161 -2864 -9281 1904 -5795 -9121 1626 -7926 -5630 0 8004 7658 5787 -3796 7674 -9116 5205 -9003 -2439 9889 3607 2138 -7701 4218 -507 -3954 -8798 -6378 4571 -5542 2172 -6564 -2979 -5050 1275 7673 0...
Output
494
Answer
494
Checker comment
ok answer is 494
 
 
21
Time: 31 ms, memory: 11868 KB
Verdict: OK
Input
100000
-203 -438 414 0 -453 -449 -127 243 -345 314 -449 -117 207 322 -43 -136 0 0 111 -44 0 -40 161 95 0 63 65 456 318 -463 0 188 433 0 43 -447 14 7 -293 103 0 12 -396 171 -426 -56 -207 -260 479 339 128 474 483 238 -231 -139 -284 -302 300 426 5 154 -324 ...
Output
55292
Answer
55292
Checker comment
ok answer is 55292
 
 
22
Time: 31 ms, memory: 11868 KB
Verdict: OK
Input
100000
295801337 986958756 -128262424 -912222696 -586823922 -527168177 263122975 -991799365 -640113760 284810929 -143134178 -338808592 452352633 -619567812 165615847 784459960 293231636 -361778854 691916885 0 829520551 -83297463 -829745650 -592483706 -44...
Output
55445
Answer
55445
Checker comment
ok answer is 55445
 
 
23
Time: 46 ms, memory: 11868 KB
Verdict: OK
Input
100000
16758488 0 3703305 26457430 -79910149 -26777912 -12450189 -61366553 92981109 21539822 43296224 -91330589 83965318 -53745084 -4413681 -79134424 69436859 -59057578 -62584529 -2554083 -34514099 -92603361 95996593 -97372663 0 -26080937 13835745 0 0 -6...
Output
55173
Answer
55173
Checker comment
ok answer is 55173
 
 
24
Time: 31 ms, memory: 11868 KB
Verdict: OK
Input
100000
5987756 0 2966249 -6905219 2463034 3221517 -7540581 7422220 8591692 -7710501 7459753 0 -1965780 -2119136 2810874 7015857 6279269 9910138 -5330232 -4405955 6341810 2288845 8517736 -7167958 5551244 -7529940 6078890 -6141751 -9001575 1714473 7204419 ...
Output
55468
Answer
55468
Checker comment
ok answer is 55468
 
 
25
Time: 46 ms, memory: 11868 KB
Verdict: OK
Input
99999
-3 -6 6 3 8 1 4 0 -9 0 5 -8 10 1 -10 -8 9 0 8 -8 -7 -2 0 7 -1 0 1 6 -10 -6 0 0 -2 -4 4 -10 2 -5 8 -6 10 -1 -9 -9 -6 4 -9 -1 6 9 9 -1 0 -2 -6 -9 -5 -8 3 -3 -8 -6 0 5 10 8 -7 4 -8 -4 10 9 -4 -10 7 -10 2 -2 7 -3 8 -3 -2 -2 -2 3 6 -2 7 1 -9 6 -6 -10 10...
Output
55192
Answer
55192
Checker comment
ok answer is 55192
 
 
26
Time: 31 ms, memory: 11860 KB
Verdict: OK
Input
99998
110 253 -160 -176 0 273 -46 -143 -237 -36 74 -61 65 200 21 188 79 0 135 -31 181 132 93 0 204 -18 244 -13 -299 -213 124 0 -55 143 61 187 -201 128 52 -276 105 -48 209 285 -272 -268 0 10 142 -220 -130 -39 -208 237 -193 -2 -234 260 0 -38 0 0 -291 -189 ...
Output
55265
Answer
55265
Checker comment
ok answer is 55265
 
 
27
Time: 46 ms, memory: 11864 KB
Verdict: OK
Input
99999
-479 373 -688 153 -924 -203 -635 0 -114 -292 -688 863 269 416 -16 535 -69 -856 -141 -739 -936 -307 -104 43 999 -45 -952 -508 717 0 641 0 0 -171 131 0 0 0 741 567 179 -59 912 938 116 -796 -767 651 215 -935 791 361 -38 -24 555 0 147 -829 -724 -841 -2...
Output
56947
Answer
56947
Checker comment
ok answer is 56947
 
 
28
Time: 31 ms, memory: 11868 KB
Verdict: OK
Input
100000
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0...
Output
100000
Answer
100000
Checker comment
ok answer is 100000
 
 
29
Time: 46 ms, memory: 11868 KB
Verdict: OK
Input
100000
242939247 -329171468 -534667181 -860386087 -140097629 980065026 -291560827 31237602 447384871 -479491153 -651442658 -921422681 -735178961 543003847 -111874041 -305256809 -671911041 -999883088 -189726962 -696922638 -284481913 829262585 660442148 47...
Output
49626
Answer
49626
Checker comment
ok answer is 49626
 
 
30
Time: 31 ms, memory: 11868 KB
Verdict: OK
Input
100000
-4 69 6 -40 -2 13 56 -85 -62 -16 -94 -71 21 78 -25 83 96 56 70 24 79 -54 -25 -51 89 -72 -19 -85 -17 11 -32 -35 -66 16 -44 36 -53 38 -77 -77 95 52 74 91 83 96 9 67 6 35 -1 -12 -42 59 -91 -43 -90 -51 -96 -85 47 -57 72 -15 -81 -71 -63 80 -53 -36 -11 ...
Output
49796
Answer
49796
Checker comment
ok answer is 49796
 
 
31
Time: 15 ms, memory: 11868 KB
Verdict: OK
Input
50000
22 -59 -29 -75 -35 29 -30 -77 51 -68 -18 9 96 0 22 -52 -45 -5 10 -40 0 56 0 92 60 70 -71 96 -96 18 7 -92 89 0 -79 -20 -70 -26 -55 -30 -78 -18 0 -69 24 -83 0 -15 1 90 -98 18 -97 -2 53 82 0 61 -48 49 57 34 74 28 0 16 16 0 96 61 7 -13 -9 0 31 -19 78 -...
Output
27613
Answer
27613
Checker comment
ok answer is 27613
 
 
32
Time: 15 ms, memory: 11868 KB
Verdict: OK
Input
60000
174 -25 -291 -16 -87 -141 -48 134 -205 -184 55 -242 -176 183 -291 171 -217 -190 95 243 -249 242 248 182 139 -47 -273 76 105 21 133 -14 -244 -150 -55 124 170 -273 -116 192 22 -76 199 -168 79 226 -299 75 187 -64 19 236 -88 63 -200 248 121 -127 -66 99...
Output
29848
Answer
29848
Checker comment
ok answer is 29848
 
 
33
Time: 15 ms, memory: 11868 KB
Verdict: OK
Input
70000
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...
Output
70000
Answer
70000
Checker comment
ok answer is 70000
 
 
34
Time: 31 ms, memory: 11864 KB
Verdict: OK
Input
80000
31521512 31319611 48704974 59635992 -40917501 -9118300 -10701509 -9233992 -16107625 15219503 74814811 96866486 26120324 63063060 69627513 -12867155 92423622 -4411021 -96380711 -60194351 43953609 8349240 62441613 -87008634 -10787909 84179672 4291890...
Output
39782
Answer
39782
Checker comment
ok answer is 39782
 
 
35
Time: 31 ms, memory: 11864 KB
Verdict: OK
Input
90000
-5 10 5 9 1 -5 1 10 -5 -10 -5 3 -4 10 6 -8 -6 -6 -6 -2 1 6 -3 -10 -5 3 5 -5 5 -6 -6 -1 6 10 -10 -2 -6 -4 1 -4 3 -4 3 -2 -6 -10 -9 9 6 -1 9 -10 -10 6 2 5 4 -8 2 -4 10 1 8 -5 3 -2 -9 -1 -6 -1 6 5 -9 -9 8 4 -3 8 10 4 -5 6 1 1 -7 -9 -8 -1 1 -4 5 -7 -6 ...
Output
44691
Answer
44691
Checker comment
ok answer is 44691
 
 
36
Time: 31 ms, memory: 11868 KB
Verdict: OK
Input
99000
445 375 6 337 283 17 215 289 120 -489 39 -80 285 275 103 139 -59 -450 -140 305 -429 -492 238 319 481 -366 170 -426 74 254 191 402 -354 359 155 360 -85 158 -111 -492 -43 -51 -30 -475 -225 -103 472 -205 -247 -71 -464 -487 258 7 -384 -61 162 -235 242 ...
Output
49416
Answer
49416
Checker comment
ok answer is 49416
 
 
37
Time: 31 ms, memory: 11868 KB
Verdict: OK
Input
99900
4119 -656 -8440 -1172 8174 -4886 179 2552 1553 6620 -853 -1498 -1821 -9672 6842 -3903 0 -6541 -6271 1293 178 8768 7488 -3430 7379 -661 -5721 3265 -1120 4097 3096 7280 -212 -2697 9848 4586 2972 8945 4903 8385 2388 6366 -4240 6348 1561 -9923 3808 -14...
Output
52223
Answer
52223
Checker comment
ok answer is 52223
 
 
38
Time: 15 ms, memory: 11868 KB
Verdict: OK
Input
60000
13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13...
Output
1
Answer
1
Checker comment
ok answer is 1
 
 
39
Time: 31 ms, memory: 11864 KB
Verdict: OK
Input
100000
1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 10000...
Output
1
Answer
1
Checker comment
ok answer is 1
 
 
40
Time: 46 ms, memory: 11864 KB
Verdict: OK
Input
100000
-1000000000 -1000000000 -1000000000 -1000000000 -1000000000 -1000000000 -1000000000 -1000000000 -1000000000 -1000000000 -1000000000 -1000000000 -1000000000 -1000000000 -1000000000 -1000000000 -1000000000 -1000000000 -1000000000 -1000000000 -100000...
Output
1
Answer
1
Checker comment
ok answer is 1