Solutions are presented as using the least memory and the fastest execution time. It also takes the top 10 most recent solutions from each language. If you want to limit to a specific index, click the "Solved" button and go to that problem.
ContestId |
Name |
Phase |
Frozen |
Duration (Seconds) |
Relative Time |
Start Time |
|---|---|---|---|---|---|---|
| 877 | Codeforces Round 442 (Div. 2) | FINISHED | False | 7200 | 267632123 | Oct. 23, 2017, 3:45 p.m. |
Solved |
Index |
Name |
Type |
Tags |
Community Tag |
Rating |
|---|---|---|---|---|---|---|
| ( 2320 ) | F | Ann and Books | PROGRAMMING | data structures flows hashing | 2500 |
In Ann's favorite book shop are as many as n books on math and economics. Books are numbered from 1 to n . Each of them contains non-negative number of problems. Today there is a sale: any subsegment of a segment from l to r can be bought at a fixed price. Ann decided that she wants to buy such non-empty subsegment that the sale operates on it and the number of math problems is greater than the number of economics problems exactly by k . Note that k may be positive, negative or zero. Unfortunately, Ann is not sure on which segment the sale operates, but she has q assumptions. For each of them she wants to know the number of options to buy a subsegment satisfying the condition (because the time she spends on choosing depends on that). Currently Ann is too busy solving other problems, she asks you for help. For each her assumption determine the number of subsegments of the given segment such that the number of math problems is greaten than the number of economics problems on that subsegment exactly by k . The first line contains two integers n and k ( 1 ≤ n ≤ 100 000 , - 10 9 ≤ k ≤ 10 9 ) — the number of books and the needed difference between the number of math problems and the number of economics problems. The second line contains n integers t 1 , t 2 , ..., t n ( 1 ≤ t i ≤ 2 ), where t i is 1 if the i -th book is on math or 2 if the i -th is on economics. The third line contains n integers a 1 , a 2 , ..., a n ( 0 ≤ a i ≤ 10 9 ), where a i is the number of problems in the i -th book. The fourth line contains a single integer q ( 1 ≤ q ≤ 100 000 ) — the number of assumptions. Each of the next q lines contains two integers l i and r i ( 1 ≤ l i ≤ r i ≤ n ) describing the i -th Ann's assumption. Print q lines, in the i -th of them print the number of subsegments for the i -th Ann's assumption. In the first sample Ann can buy subsegments 1;1, 2;2, 3;3, 2;4 if they fall into the sales segment, because the number of math problems is greater by 1 on them |
| 55362 |
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
|---|---|---|---|---|---|---|---|---|---|---|---|
| 31690546 | Faimerth | F | Oct. 24, 2017, 5:19 p.m. | OK | GNU C | TESTS | 78 | 327 | 27136000 | 2500 | |
| 31690231 | Faimerth | F | Oct. 24, 2017, 5:08 p.m. | OK | GNU C | TESTS | 78 | 327 | 27136000 | 2500 | |
| 31687719 | Faimerth | F | Oct. 24, 2017, 3:49 p.m. | OK | GNU C | TESTS | 78 | 1450 | 164249600 | 2500 | |
| 31687972 | Faimerth | F | Oct. 24, 2017, 3:56 p.m. | OK | GNU C | TESTS | 78 | 1996 | 48742400 | 2500 | |
| 31666182 | hhhwsqhhh | F | Oct. 24, 2017, 1:41 a.m. | OK | GNU C++ | TESTS | 78 | 140 | 14950400 | 2500 | |
| 40979417 | ReaLNero1 | F | July 30, 2018, 5:04 p.m. | OK | GNU C++ | TESTS | 78 | 155 | 12800000 | 2500 | |
| 32090283 | Thefinal | F | Nov. 6, 2017, 9:13 a.m. | OK | GNU C++ | TESTS | 78 | 202 | 13619200 | 2500 | |
| 31670722 | zxyer | F | Oct. 24, 2017, 6:25 a.m. | OK | GNU C++ | TESTS | 78 | 217 | 10956800 | 2500 | |
| 31973646 | wzp233 | F | Nov. 2, 2017, 9:27 a.m. | OK | GNU C++ | TESTS | 78 | 218 | 18124800 | 2500 | |
| 31737970 | PeterShao | F | Oct. 26, 2017, 12:28 p.m. | OK | GNU C++ | TESTS | 78 | 249 | 60108800 | 2500 | |
| 31731097 | xiaocainiao123 | F | Oct. 26, 2017, 7:20 a.m. | OK | GNU C++ | TESTS | 78 | 265 | 8396800 | 2500 | |
| 31715412 | wings_forever | F | Oct. 25, 2017, 3:17 p.m. | OK | GNU C++ | TESTS | 78 | 265 | 11366400 | 2500 | |
| 31732942 | imone | F | Oct. 26, 2017, 8:55 a.m. | OK | GNU C++ | TESTS | 78 | 280 | 17715200 | 2500 | |
| 31730231 | xiaocainiao123 | F | Oct. 26, 2017, 6:38 a.m. | OK | GNU C++ | TESTS | 78 | 296 | 10444800 | 2500 | |
| 52820318 | luogu_bot2 | F | April 16, 2019, 11:39 a.m. | OK | GNU C++11 | TESTS | 78 | 140 | 10035200 | 2500 | |
| 52820267 | Fubuki | F | April 16, 2019, 11:38 a.m. | OK | GNU C++11 | TESTS | 78 | 140 | 10035200 | 2500 | |
| 52928846 | time_interspace | F | April 17, 2019, 11:11 p.m. | OK | GNU C++11 | TESTS | 78 | 171 | 8806400 | 2500 | |
| 31683063 | Jori | F | Oct. 24, 2017, 1:27 p.m. | OK | GNU C++11 | TESTS | 78 | 187 | 10649600 | 2500 | |
| 65112513 | Haunted_Cpp | F | Nov. 16, 2019, 12:20 a.m. | OK | GNU C++11 | TESTS | 78 | 187 | 17920000 | 2500 | |
| 36708654 | mengbierr | F | March 29, 2018, 4:08 a.m. | OK | GNU C++11 | TESTS | 78 | 187 | 19865600 | 2500 | |
| 32333870 | Noureldin | F | Nov. 15, 2017, 2:04 p.m. | OK | GNU C++11 | TESTS | 78 | 202 | 6041600 | 2500 | |
| 32107242 | krijgertje | F | Nov. 6, 2017, 11:31 p.m. | OK | GNU C++11 | TESTS | 78 | 202 | 6451200 | 2500 | |
| 31737509 | DZYO | F | Oct. 26, 2017, 12:08 p.m. | OK | GNU C++11 | TESTS | 78 | 202 | 8396800 | 2500 | |
| 49036687 | Chenqiqian | F | Jan. 27, 2019, 3:51 a.m. | OK | GNU C++11 | TESTS | 78 | 202 | 10240000 | 2500 | |
| 31666508 | whjhr | F | Oct. 24, 2017, 2:07 a.m. | OK | GNU C++14 | TESTS | 78 | 171 | 13721600 | 2500 | |
| 31931113 | Egor.Lifar | F | Oct. 31, 2017, 6:51 p.m. | OK | GNU C++14 | TESTS | 78 | 186 | 12390400 | 2500 | |
| 49530049 | nhho | F | Feb. 6, 2019, 1:25 p.m. | OK | GNU C++14 | TESTS | 78 | 217 | 6860800 | 2500 | |
| 41673215 | Zarxdy34 | F | Aug. 17, 2018, 6:34 a.m. | OK | GNU C++14 | TESTS | 78 | 218 | 6451200 | 2500 | |
| 31695629 | StarCuriosity | F | Oct. 24, 2017, 11:42 p.m. | OK | GNU C++14 | TESTS | 78 | 233 | 8704000 | 2500 | |
| 69893977 | slizkov | F | Jan. 31, 2020, 11:06 a.m. | OK | GNU C++14 | TESTS | 78 | 233 | 13209600 | 2500 | |
| 31893505 | Out_of_Cage | F | Oct. 30, 2017, 12:40 p.m. | OK | GNU C++14 | TESTS | 78 | 234 | 7987200 | 2500 | |
| 31665979 | flukehn | F | Oct. 24, 2017, 1:24 a.m. | OK | GNU C++14 | TESTS | 78 | 249 | 10342400 | 2500 | |
| 31829235 | Jester | F | Oct. 28, 2017, 8:34 a.m. | OK | GNU C++14 | TESTS | 78 | 249 | 11059200 | 2500 | |
| 68338084 | pikmike | F | Jan. 7, 2020, 12:27 a.m. | OK | GNU C++14 | TESTS | 78 | 249 | 11571200 | 2500 | |
| 50734874 | hznu_kk | F | March 3, 2019, 12:28 p.m. | OK | GNU C++17 | TESTS | 78 | 218 | 10342400 | 2500 | |
| 51256127 | gsoares | F | March 13, 2019, 11:22 a.m. | OK | GNU C++17 | TESTS | 78 | 218 | 10649600 | 2500 | |
| 51240781 | gsoares | F | March 12, 2019, 9:47 p.m. | OK | GNU C++17 | TESTS | 78 | 249 | 8294400 | 2500 | |
| 54098766 | ZGQ | F | May 14, 2019, 2:34 p.m. | OK | GNU C++17 | TESTS | 78 | 249 | 25702400 | 2500 | |
| 54098732 | ZGQ | F | May 14, 2019, 2:33 p.m. | OK | GNU C++17 | TESTS | 78 | 249 | 25702400 | 2500 | |
| 59213874 | hbi1998 | F | Aug. 21, 2019, 9:28 a.m. | OK | GNU C++17 | TESTS | 78 | 264 | 10547200 | 2500 | |
| 49514006 | markotee | F | Feb. 5, 2019, 11:30 p.m. | OK | GNU C++17 | TESTS | 78 | 264 | 18534400 | 2500 | |
| 54098769 | vjudge1 | F | May 14, 2019, 2:34 p.m. | OK | GNU C++17 | TESTS | 78 | 265 | 25702400 | 2500 | |
| 56004656 | llbra9z | F | June 24, 2019, 2:51 p.m. | OK | GNU C++17 | TESTS | 78 | 280 | 12185600 | 2500 | |
| 66970899 | 28164843TuNA | F | Dec. 15, 2019, 1:10 p.m. | OK | GNU C++17 | TESTS | 78 | 295 | 11264000 | 2500 | |
| 47277561 | ZeyadKhattab | F | Dec. 19, 2018, 8:25 p.m. | OK | Java 8 | TESTS | 78 | 498 | 19353600 | 2500 | |
| 47277885 | ZeyadKhattab | F | Dec. 19, 2018, 8:39 p.m. | OK | Java 8 | TESTS | 78 | 514 | 19353600 | 2500 | |
| 33914071 | tmwilliamlin168 | F | Jan. 5, 2018, 2:12 a.m. | OK | Java 8 | TESTS | 78 | 529 | 24883200 | 2500 | |
| 40484409 | Ahmad | F | July 17, 2018, 3:47 p.m. | OK | Java 8 | TESTS | 78 | 624 | 34304000 | 2500 | |
| 33656132 | poikniok | F | Dec. 26, 2017, 7:17 p.m. | OK | Java 8 | TESTS | 78 | 670 | 49356800 | 2500 | |
| 33656121 | poikniok | F | Dec. 26, 2017, 7:16 p.m. | OK | Java 8 | TESTS | 78 | 701 | 49356800 | 2500 | |
| 33742869 | RP_9 | F | Dec. 28, 2017, 5:59 p.m. | OK | Java 8 | TESTS | 78 | 717 | 37376000 | 2500 | |
| 39726834 | Dobo_boy | F | June 27, 2018, 8:07 p.m. | OK | Java 8 | TESTS | 78 | 997 | 41676800 | 2500 | |
| 31695252 | mathmaniac | F | Oct. 24, 2017, 10:52 p.m. | OK | Java 8 | TESTS | 78 | 1014 | 38809600 | 2500 | |
| 31733186 | donli | F | Oct. 26, 2017, 9:07 a.m. | OK | Java 8 | TESTS | 78 | 1075 | 31948800 | 2500 | |
| 31692323 | Maffka | F | Oct. 24, 2017, 7:17 p.m. | OK | MS C++ | TESTS | 78 | 389 | 22425600 | 2500 | |
| 34635558 | hatoo | F | Jan. 28, 2018, 2:31 p.m. | OK | Rust | TESTS | 78 | 327 | 23142400 | 2500 | |
| 34635281 | hatoo | F | Jan. 28, 2018, 2:21 p.m. | OK | Rust | TESTS | 78 | 327 | 23142400 | 2500 | |
| 34635494 | hatoo | F | Jan. 28, 2018, 2:29 p.m. | OK | Rust | TESTS | 78 | 343 | 23142400 | 2500 |
Back to search problems