Common Boarddeleted Edited by moderator 11.08.2022 18:56 var m,n,i,j,k,s,l:integer; A: array [1..15000] of LongInt; B: array [1..1000000] of LongInt; begin s:=0; readln(n); for i:=1 to n do readln(A[i]); readln(m); for j:=1 to m do begin readln(B[j]); end; i := 1; j := n; k := 1; for l:=1 to m do begin while (i <=j) do begin k := (i + j) div 2; if B[l] > A[k] then i := k + 1 else j := k -1;
end; if A[k] = B[l] then s:=s+1; end; writeln(); writeln(s); readln; end. Try this test: 3 10 11 12 3 12 11 10 result must be 3 or no :) Try this test: 3 10 11 12 3 12 11 10 In your program teacher's dates should not be the same. But once you will fix this your program won't pass test 8 because of time limit. You have to use binary search. And in binary search there can be the same teacher's dates. My code doesn't leave empty line after the last query. What can be the cause of WA2? Seeing many people also got WA2 :(( Edited by author 21.04.2017 07:33 Edited by author 21.04.2017 07:33 if no word found with any query dont print any new line Can someone help me? Please? I do it with Python3 ,and does not print out empty line after last queue here's my code: def getSecond(temp): return temp[1] if __name__ == '__main__': while True: try: N = int(input()) Words = [] for n in range(N): Words.append(input().split()) Words[n][1] = int(Words[n][1]) M = int(input()) Beginners = [] for m in range(M): Beginners.append(input()) for mm in range(M): start = list(Beginners[mm]) matchs = [] for nn in range(N): word = list(Words[nn][0]) flag = True for s in range(len(start)): if start[s] != word[s]: flag = False break if(flag): matchs.append(Words[nn]) if matchs != []: matchs.sort() matchs.sort(key = getSecond, reverse = True) count = 0 for match in matchs: if count > 10: break print(match[0]) count += 1
if mm != M-1: print() except: break
if no word found with any query dont print any new line You need to find formula for progression - it is a square equation, and then just solve it. I this problem you can choice X+Z, Y or X, Y+Z if you have A, B, C Edited by author 05.12.2019 20:58 Task: old bus routes can be equal to 1, and bus stops can also be equal to 1 .... Does it make any sense? Really? What did the authors think of when they put such conditions? my email is LiuyangElvis@gmail.com thanks for help! 10 7 BA AA AA AA AA AA AB AB AB AB AB ANSWER:NO Good luck! If you wa, try these HELLO. WORLD - IS IT CORRECT? - YES, IT IS. thank you!This is test help me!!!))) I get AC! Thanks, My algo failed because of this case in test 2; Answer is number in the (1, 1) of this matrix |k - 1 k - 1| ^ N | 1 0 | Example: If n is 2 and k is 10 then |9 9| ^ 2 = |90 81| |1 0| |9 9| And answer is 90. Use fast power algorithm to count it in O(logn). I got WA,who can give me some tests? Hope this will help. submission ID of an AC solution is 76436 50 1000 71 742 876 37 913 297 71 517 146 62 734 670 67 122 568 70 521 331 68 529 255 100 831 713 53 946 579 80 72 568 19 338 683 40 914 523 12 339 692 56 111 463 40 376 940 40 387 459 15 767 3 56 408 195 16 778 723 83 245 344 27 376 961 89 639 173 81 139 498 70 345 408 56 555 470 14 572 979 29 426 872 17 340 491 40 153 317 18 368 977 42 124 140 35 20 341 70 77 443 1 914 11 77 948 658 15 100 83 16 197 811 75 308 923 49 691 910 78 698 200 87 789 908 60 905 807 96 55 432 38 31 572 42 948 127 42 545 250 28 514 982 91 102 445 51 679 557 17 873 976
Minimum possible cost: 275665.59
50 1000 45 292 824 20 386 715 71 692 204 71 956 78 82 784 432 10 634 360 79 391 805 41 793 303 77 653 596 81 708 389 95 840 856 22 54 380 60 197 699 1 901 354 64 797 555 37 475 800 18 909 626 46 993 186 88 640 868 32 746 326 8 768 778 91 766 66 24 683 179 33 10 262 100 435 603 57 424 869 59 877 853 54 837 137 27 116 474 34 643 695 28 773 131 81 9 462 65 105 991 5 181 260 76 909 102 85 706 446 5 287 24 58 276 162 35 987 671 39 901 813 58 96 102 55 254 274 87 497 737 41 60 98 18 717 944 85 82 804 42 679 49 68 470 85 82 519 230 24 803 761
Minimum possible cost: 309434.71
50 1000 42 98 421 55 635 989 74 606 405 99 210 617 64 447 485 28 354 110 69 665 789 83 608 917 32 850 117 31 662 314 89 751 17 6 578 799 80 27 100 65 245 812 51 742 312 15 653 987 20 407 806 64 647 342 66 385 980 72 517 237 25 493 663 18 125 802 6 687 408 77 919 715 20 928 977 53 141 966 20 564 412 78 390 441 12 219 163 38 408 65 83 913 630 97 374 693 98 430 739 59 719 237 75 479 934 64 558 505 24 327 633 54 0 114 29 169 48 66 508 661 80 764 669 36 305 61 12 695 840 13 933 813 73 309 268 31 672 838 8 691 964 100 146 620 99 392 729 88 88 691
Minimum possible cost: 291969.15
50 877 89 644 415 29 55 779 45 299 56 44 476 946 85 938 827 71 152 532 26 988 970 40 613 648 90 145 737 41 317 343 50 489 546 96 434 985 39 809 493 55 739 395 59 542 269 72 106 833 17 924 708 66 521 953 78 358 21 44 502 1000 74 546 627 98 337 664 99 251 34 87 610 821 3 714 13 52 280 900 84 261 845 59 56 357 18 613 333 48 71 836 34 367 144 34 28 536 8 219 246 31 999 234 12 100 673 48 88 812 48 850 676 63 245 122 13 641 526 68 660 163 77 327 968 52 480 821 14 739 544 85 206 521 96 724 904 25 863 35 45 14 646 94 347 941 37 879 589 19 852 953
Minimum possible cost: 221384.20
50 534 64 422 648 95 419 88 8 846 911 49 447 706 31 924 619 47 68 151 57 543 99 30 542 338 33 582 546 70 339 610 25 228 180 4 163 502 38 856 823 37 846 775 10 987 290 19 29 435 17 862 744 76 352 355 38 913 134 70 30 182 10 906 226 65 994 391 35 979 889 25 7 788 85 3 482 99 157 468 44 59 879 51 692 318 7 35 835 28 99 610 76 869 845 24 516 223 69 415 144 4 622 490 21 840 877 84 243 806 87 423 534 70 396 847 63 195 365 81 627 808 50 593 375 92 754 251 70 745 514 23 539 395 65 788 739 7 25 615 55 154 269 18 288 33 54 860 760 41 752 72
Minimum possible cost: 102215.67
50 645 72 407 246 20 732 810 45 545 320 26 844 486 68 695 794 77 156 21 71 681 328 76 774 911 81 216 272 19 769 547 25 899 891 28 615 873 2 186 14 69 848 643 90 407 497 75 703 621 61 913 147 7 388 696 93 313 982 7 341 197 66 372 765 10 990 729 80 159 8 57 611 45 87 539 890 91 589 131 24 536 957 53 63 53 54 680 252 41 439 600 18 603 337 33 826 623 80 54 134 13 958 475 76 596 137 19 867 574 86 750 815 96 359 922 59 648 739 88 451 977 6 569 358 71 185 683 76 497 285 57 42 231 5 210 793 47 145 323 46 925 652 78 175 982 15 158 909 26 898 197
Minimum possible cost: 114316.36
50 415 1 468 33 4 964 197 3 44 219 4 190 69 2 657 560 3 541 34 4 934 456 9 976 383 7 887 151 9 859 806 10 130 370 2 289 678 8 842 330 6 732 811 1 499 0 3 384 863 4 411 254 9 480 549 9 838 560 6 920 825 1 971 186 4 907 395 4 493 99 3 490 373 5 653 919 9 924 566 1 134 921 8 311 9 3 249 341 8 925 765 5 444 602 2 790 44 8 635 614 10 206 140 9 744 685 1 896 809 4 847 644 10 44 452 3 820 365 10 570 998 6 221 821 4 234 592 9 464 765 5 613 402 7 224 220 8 179 837 7 498 606 7 739 532 1 854 711 9 855 485
Maximum possible amount: 275 Minimum possible cost: 150432.00 Oh. I mean 776436 that's strange, my AC program gives at your first 3 tests slightly different results... you made DP with A[i][j] -> i workshops and j brooms right? Thats really strange 8(. Anyway I have submitted my program once more. AC. Submission id is 780543. The DP is same as you described... Something fishy.... It's uncorrect tests. So first broom always must have hidest cost then last Try this one: 2 2 1 5 5 1 4 4 Minimum possible cost: 9.00 Try to use double instead of float. there is some problem in greed algorithm,such as 2 2 3 80 80 3 100 0 the best strategy is 100,50 while greed algorithm gets 80,80 Best strategy is 150.00 Edited by author 02.12.2019 13:48 There is a country named [Сensored]. In this country the national instrument is called "balalayka". In the capital of [Сensored] the biggest square is called Red Square... I don't have nothing against [Сensored], but there are some idiots who live there (like Gyrinovskiy), that like to say before think! And what thay say is very politically uncorrect! I hope that authors of the problem are not such idiots. I'd like to wish the authors of the problem to think more before write such things in the problem statement. It would be very nice for you to change the problem statement completly. best regards, Ostap Korkuna. I want to propose you to make your own contest - and I will be really pleased to read another funny story about country named [Censored] ;) Anyway, the task statement offends me in particular and I belive that there are a lot of other respected people, who are offended by such kind of "jokes". In my opinion this "joke" has overstepped the limits of innocents... See, one may feel offended even if I write "the sky is blue". No concrete names of people and country are mentioned. Why do you think the story is about your country I respect very much? There are a lot of countries in the world who deal with Russian gas. Not all of them steal it in fact ;) But if you associate [Censored] with you country - you must have some reasons... More people from your country will complain about this problem - more people may think something politically incorrect about it. But we are not guilty of it, aren't we? Relax, the story is really cool. Maybe next time we will write something funny about the presidential elections in [Censored] ;))) Edited by author 24.04.2006 23:58 Dmitry, it seems that Michael Rybak is not the only man offended by this task statement. Isn't it? As the administrator of this site I DEMAND this task statement to be rewritten. It DOES offend visitors of this site regardless of which coutry is hidden under phrase '[Censored]'. Otherwise you have a choice: either I will change task statement by myself or task will be hidden from public (or completely removed from archive). Everybody who got offended by the statement of this task, let me know about it in this thread. I completely agree with you. Please, avoid offending messages. Just let me know that there are a lot of people who wants Timus to be over politics. And let me know, which solution would you prefer: change of statement or task removal. as Russian citizen i think that shuld corect not only tsk about [cenzored] country but and 1457(about old pop), and ALL task in timus archive wich creat wrong understending about my GREAT matherland :) First, if the statement will be changed by you, all our twenty problems will be locked until we may come to some decision. And lots of programmers who have sense of humour and want to solve these problems will thank you very much for what you achieved because of several malcontents. Second, now Ilya Grebnov, Nikita Rybak and me are trying to think out something. We need at least one day to do it. Third, if you think it is so just and noble of you to put pressure upon us, you are mistaken. You forget something. We are not your subordinates. You do not pay us money for what we are doing here - for the sake of Timus Online Judge by the way. As you could see, our contests are much more popular than any contests before. We are still the Top Coders. So try to learn to respect us - at least as this site's best programmers - OK? P.S. Now we are working at "Pascal vs. C++. Version 2" problem which is going to be added to the Volume 4 soon. But because of you we had to slow down our activity. Thank you very much, it is very useful for Timus. ============================================================ IBM is short, Pascal is forever! Edited by author 25.04.2006 03:04 Our, i'm so impressed by you kindness, really , yes you won't get paid for changing problem statement, but i'd like to inform you that in civilized world there exists such thing as "law" and your problem can be recognized as offending honour of some country and peoople, so try be more carefull in future plz. Of course i understand that changing problem statement is a really exhausting job, so thank you for this great effort! No one wants to put pressure on you! We just want to make problem statements nonpolitical and inoffensive. You may assume it as a basic rules of this site. JOKE? Where is a joke? Your Country repeatedly do it. And every time your Goverment with the disgrace plead guilty. You may call it "technical selection of gas" but we call a spade a spade. Goverment plead guilty and I don't understand why you think that the statement is pollitically incorect. We know that our geverment nothing better. And we say about it, for example, in the statement of problem # 1457 Edited by author 17.06.2006 16:44 respect to authors. others can kill themselves by hitting the wall. Can anybody upload original statement? Школота detected. Such an intellectual "humor" from authors. It was kind of surprise to find such shet on Timus. Edited by author 02.12.2019 12:02 Edited by author 02.12.2019 12:02 first...you must know that there is only one test case, ans this test case contents lots of tests... second...if you used the floyed to calculate the minimum circle,you must check the path you recorded.and, yes, the order of the crossing is not important. ok,I WA on the recording of the path,because I ignored that floyed will change the mid node of my path... sorry for my english... there is one test case that may help you : 98 146 1 2 1 2 3 300 3 4 1 4 5 300 5 6 1 6 7 300 7 8 1 8 9 300 9 10 1 10 11 300 11 12 1 12 13 300 13 14 1 14 15 300 15 16 1 16 17 300 17 18 1 18 19 300 19 20 1 20 21 300 21 22 1 22 23 300 23 24 1 24 25 300 25 26 1 26 27 300 27 28 1 28 29 300 29 30 1 30 31 300 31 32 1 32 33 300 33 34 1 34 35 300 35 36 1 36 37 300 37 38 1 38 39 300 39 40 1 40 41 300 41 42 1 42 43 300 43 44 1 44 45 300 45 46 1 46 47 300 47 48 1 48 49 300 50 51 300 51 52 1 52 53 300 53 54 1 54 55 300 55 56 1 56 57 300 57 58 1 58 59 300 59 60 1 60 61 300 61 62 1 62 63 300 63 64 1 64 65 300 65 66 1 66 67 300 67 68 1 68 69 300 69 70 1 70 71 300 71 72 1 72 73 300 73 74 1 74 75 300 75 76 1 76 77 300 77 78 1 78 79 300 79 80 1 80 81 300 81 82 1 82 83 300 83 84 1 84 85 300 85 86 1 86 87 300 87 88 1 88 89 300 89 90 1 90 91 300 91 92 1 92 93 300 93 94 1 94 95 300 95 96 1 96 97 300 97 98 1 1 50 5 2 51 5 3 52 5 4 53 5 5 54 5 6 55 5 7 56 5 8 57 5 9 58 5 10 59 5 11 60 5 12 61 5 13 62 5 14 63 5 15 64 5 16 65 5 17 66 5 18 67 5 19 68 5 20 69 5 21 70 5 22 71 5 23 72 5 24 73 5 25 74 5 26 75 5 27 76 5 28 77 5 29 78 5 30 79 5 31 80 5 32 81 5 33 82 5 34 83 5 35 84 5 36 85 5 37 86 5 38 87 5 39 88 5 40 89 5 41 90 5 42 91 5 43 92 5 44 93 5 45 94 5 46 95 5 47 96 5 48 97 5 49 98 5 50 49 3 the answer is 49 50 1 2 51 52 3 4 53 54 5 6 55 56 7 8 57 58 9 10 59 60 11 12 61 62 13 14 63 64 15 16 65 66 17 18 67 68 19 20 69 70 21 22 71 72 23 24 73 74 25 26 75 76 27 28 77 78 29 30 79 80 31 32 81 82 33 34 83 84 35 36 85 86 37 38 87 88 39 40 89 90 41 42 91 92 43 44 93 94 45 46 95 96 47 48 97 98 Hello! I pass your test data but I still get WA,why? Is there any other trick? Sorry for my poor english too. :) Oh,I get AC! Beacuse my inf is too large. It should be small than INT_MAX/3. So somebody else who get WA should notice it. More test data: 5 0 6 1 1 2 3 -1 Edited by author 02.08.2011 08:24 Edited by author 02.08.2011 08:25 my answer is 1 2 51 52 3 4 53 54 5 6 55 56 7 8 57 58 9 10 59 60 11 12 61 62 13 14 63 64 15 16 65 66 17 18 67 68 19 20 69 70 21 22 71 72 23 24 73 74 25 26 75 76 27 28 77 78 29 30 79 80 31 32 81 82 33 34 83 84 35 36 85 86 37 38 87 88 39 40 89 90 41 42 91 92 43 44 93 94 45 46 95 96 47 48 97 98 49 50 but it is stall WA in test one! who can give more test cases? 6 9 1 2 1 2 3 100 3 4 1 4 5 100 5 6 1 6 1 100 1 4 5 2 5 5 3 6 5 1 2 5 6 3 4 Edited by author 20.04.2013 19:32 Thanks, you are true hero! consider about “list are not decreasing” good point for wa16 i was answering for 0 days If you are a C++ user, learn about ordered_set in Policy Based Data Structures. My code: #include<iostream> #include<map> #include<string> using namespace std; #define DL 0 //Debug log string SIB; //String input bufer unsigned long CIB; //Cost input bufer map<string, unsigned long>DC; //Devices cost map<string, unsigned long>DR; //Devices repits unsigned short RR; //Repits record unsigned long RC; //Record cost string O; //Output int main() { for (unsigned short i = 0; i < 6; i++) { cin >> SIB; cin >> SIB; cin >> CIB; if (CIB > RC) RC = CIB; if(DC[SIB] == 0 || DC[SIB] > CIB) DC[SIB] = CIB; DR[SIB]++; if (DR[SIB] > RR) RR = DR[SIB]; } if (DL) { cout << endl; cout << "Name repits cost:" << endl; for (auto i : DR) { cout << i.first << " " << i.second << " " << DC[i.first] << endl; } cout << endl; } for (auto i : DR) { if (i.second == RR) { if (DC[i.first] < RC) { RC = DC[i.first]; O = i.first; } } } cout << O; } Give me plz some test Edited by author 30.11.2019 17:00 #include<stdio.h> #include<math.h> int main(){ int n; scanf("%d",&n); if(n==0){printf("%d",1);} else if(n>0){printf("%d",(n*(n+1))/2);} else{ n=fabs(n); printf("%d",-1*(((n*(n+1))/2)-1)); } return 0; } Edited by author 30.11.2019 13:52 Who can give me an AC program? no Edited by author 29.11.2019 21:57 Edited by author 29.11.2019 21:57 maybe it is not the best solution, but using System; using System.Collections.Generic; namespace _1026 { class Program { static void Main(string[] args) { int n = int.Parse(Console.ReadLine()); List<int> z = new List<int>(); for(int i = 0; i < n; i++) z.Add(int.Parse(Console.ReadLine())); z.Sort(); Console.ReadLine(); int k = int.Parse(Console.ReadLine()); for (int i = 0; i < k; i++) Console.WriteLine(z[int.Parse(Console.ReadLine())-1]); } } } well.... C# helps a lot. but i really think figure out yourself is better. PS: no sort is required actually. If you know the length of array it is better to create array, not to use List<>. Array is faster :) In this case you needn`t a lot of economy of time, but in some cases this can be critical. |
|