| Show all threads Hide all threads Show all messages Hide all messages |
| решение С# | Terekhin Grigory | 1787. Turn for MEGA | 1 Mar 2018 15:32 | 1 |
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace РџРѕРІРѕСЂРѕС‚ { class Program { static void Main(string[] args) { string[] mas = Console.ReadLine().Split(' '); int k = int.Parse(mas[0]); int n = int.Parse(mas[1]); int[] A = Console.ReadLine().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Select(i => int.Parse(i)).ToArray(); int M = 0; for (int i = 0; i < n; i++) { M += A[i]; if (M - k >= 0) {M -= k;} else {M = 0;} } Console.WriteLine(M); } } } Надеюсь понятно всё. |
| The code on Python work correct whe same code on Ruby have wrong answer #3 | Valentin Gulyaev | 1785. Lost in Localization | 26 Feb 2018 00:33 | 3 |
Have solved this task in Python many years ago. How test my code on Python and have Accept This code on Ruby have WA on test №3 Stay tuned and inform us as quick as possible. |
| WA#3 | Lakers | 1872. Spacious Office | 25 Feb 2018 17:00 | 3 |
WA#3 Lakers 19 Oct 2011 09:12 My program gets wa#3 test 3: 6 1 2 3 4 5 6 1 1 1 6 2 3 3 3 4 4 5 5 my program out: Perfect! 1 3 4 5 6 2 it's wrong? Edited by author 25.02.2018 18:18 |
| It's very easy to overcome TLE. | balandini | 1353. Milliard Vasya's Function | 25 Feb 2018 04:49 | 4 |
If you have program which gives right answer for the problem, but it's too slow and gets TLE, then you may just calculate answers for every possible input(there are only 81 possible variants of input, so you can calculate them all) and then create another program: put array of 81 possible answers in this program and them just read s from input and write in output corresponding answer from the array. I had made such program and it got AC. In this case what is the use solving this problem. Edited by author 25.02.2018 04:48 Edited by author 25.02.2018 04:49 Edited by author 25.02.2018 04:49 Edited by author 25.02.2018 04:49 In this case what is the use solving this problem. |
| If you got RE at test case 9 | Thomas0726 | 1061. Buffer Manager | 24 Feb 2018 13:41 | 1 |
it may help: line = Console.ReadLine(); while (line.Length < N) { line += Console.ReadLine(); } |
| WA 19 | Lightless [Samara SAU] | 1963. Kite | 24 Feb 2018 01:28 | 1 |
WA 19 Lightless [Samara SAU] 24 Feb 2018 01:28 |
| Why I get a TLE #6 ? | Yang Tianyi | 1018. Binary Apple Tree | 23 Feb 2018 06:47 | 4 |
Just like what I have said,I got a TLE and execution time is 1.029. Who can help me? Now I get an AC Just change "if(!y)" into "if(!y||!x)" |
| About TLE and Recursion | daftcoder [Yaroslavl SU] | 1018. Binary Apple Tree | 23 Feb 2018 06:45 | 5 |
I got TL#6. After that just a little bit updated my solution: int max( int pos, int len ) { ..if ( ch[pos][len] ) ....return dp[pos][len]; --- ....ch[pos][len] = 1; ....dp[pos][len] = res; ....return res; --- } and got AC in 0.015s. Edited by author 23.03.2010 20:30 I get TLE in #6 too , can you explain in detail? Well, I checked my solution and it didn't seem that could exceed the time limit... Weird... I've got TLE #6 too. Can you explain in detail??I'm afraid i can't understand..... oh,now I get AC.Just a little mistakes. |
| WA at #1 ?? Try this data... | arena_zp | 1018. Binary Apple Tree | 23 Feb 2018 06:14 | 6 |
6 4 1 2 20 2 5 100 2 3 20 6 3 70 4 1 10 by the way : before you use the dynamic programming on the tree structure, be sure you have build the tree correctly. That's why I got WA. Source Code is available at : ecnu_zp@yahoo.cn I guess this test is incorrect, because of statement: " any biparous branch splits up to exactly two new branches", but node 3 has only one branch. As I can see here is 2 possible trees. 1 and 3 can be root 6 \ 5 3 \ / 4 2 \ / 1 4 \ 5 1 \ / 6 2 \ / 3 Edited by author 20.12.2015 15:47 wrong test case, there will always be zero or two children of any node. |
| can anyone explain me how to do it??? | Kirill | 1878. Rubinchik's Cube | 21 Feb 2018 15:08 | 1 |
explain me the way of doing it or give a solution Edited by author 21.02.2018 16:21 |
| Test case 2 | Wei Zhang | 2034. Caravans | 20 Feb 2018 22:49 | 1 |
What is the second test case? |
| More test cases | azikar24 | 1210. Kind Spirits | 20 Feb 2018 00:09 | 1 |
Make sure your graph is more than 1296 and try these 3 2 1 2 0 1 5 0 * 3 1 8 2 3 0 1 -5 0 2 25 0 * 2 1 8 2 22 3 -15 0 2 19 3 -50 0 ans = -20 =========================== 4 2 1 2 0 1 5 0 * 4 1 8 2 3 0 1 -5 0 2 25 0 1 22 2 -3 0 * 3 1 8 2 22 3 -15 0 2 19 3 -50 0 4 -1 2 -5 0 * 4 1 -8 2 18 0 1 -5 0 2 -19 3 -22 0 1 12 0 ans= -39 ============================== 2 2 1 2 0 1 5 0 * 4 1 8 2 3 0 1 -5 0 2 25 0 1 22 2 -3 0 ans = -3 ========================== 4 2 1 2 0 1 5 0 * 4 1 81 2 23 0 1 56 0 2 25 0 1 22 2 -31 0 * 3 1 8 2 22 3 -15 0 2 19 3 -50 0 4 -1 2 -5 0 * 4 1 82 2 18 0 1 59 0 2 39 3 52 0 1 112 0 ans = -2 |
| solution hints | imaginary friend | 1303. Minimal Coverage | 17 Feb 2018 04:30 | 1 |
1) greedy works here, although it's not that much obvious how *correct* greedy should look like 2) 5th test case, that didn't pass for me: 12 -3 10 -2 8 -1 16 0 0 Edited by author 17.02.2018 04:30 |
| bugurt & advice | imaginary friend | 2098. Lada Priora | 15 Feb 2018 03:30 | 1 |
the only idea/key take-away of this problem is to properly combine calculation of integer and floating point numbers Edited by author 15.02.2018 03:31 |
| Почему не принимать все же верно frePascal 2.6 | Dok32 | 1000. A+B Problem | 14 Feb 2018 23:35 | 3 |
var a,b,c:real; begin read(a,b); writeln(a+b); end. Edited by author 14.02.2018 23:36 Edited by author 14.02.2018 23:36 |
| WA6 | Lightless [Samara SAU] | 2089. Experienced coach | 14 Feb 2018 01:02 | 1 |
WA6 Lightless [Samara SAU] 14 Feb 2018 01:02 Try this: 2 2 1 2 1 2 Ans: Yes 1 2 |
| How to fix WA 2 | Aditya Paliwal | 2093. All Roads Lead to Snowdrift | 13 Feb 2018 21:09 | 1 |
It is okay to use an edge if the next cleaning for this edge begins at the exact moment when you have crossed the edge. In other words a road is cleaned during the open interval (s_i, f_i). |
| No subject | IT | 1617. Flat Spots | 13 Feb 2018 16:03 | 2 |
Edited by author 12.03.2016 20:21 n = int(input()) a = [] summ = 0 for i in range(n): a.append(int(input())) b = list(set(a)) for i in range(len(b)): c=a.count(b[i]) if c > 3: summ+=c//4 print(summ) |
| eps | Anatoliy V Tomilov | 1369. Cockroach Race | 13 Feb 2018 15:32 | 4 |
eps Anatoliy V Tomilov 24 Jan 2018 02:03 Epsilon to compare squared distances must be exactly 1.0 / (1 << 24) (at least for M*N algo). Even 23 and 25 leads to WA. Re: eps Anatoliy V Tomilov 5 Feb 2018 17:11 (std::numeric_limits< float >::epsilon() / 2) is absolute accuracy needed overall. You can invent twofold float-then-double algorithm to sieve bad points beforehand. For single precision algorithm part you have to use 20.1f (20 + small constant) "epsilon" to compare squared distances in case if you use <= or >= operator (say, vcmpge_oqps or vcmple_oqps instructions) and 28.2f (28 + small constant) in case of strict inequality. Surely you can invent adaptive algorithm to infer relative accuracy needed in particular test case, which takes into account max abs differences of input point coordinates. epsilon should be explicitly specified in the problem statement, it is not hard to make a test to break even simplest O(n*m) double precision solution. Re: eps Anatoliy V Tomilov 13 Feb 2018 15:32 I totally agree. The problem should be reformulated in integers or other way to make use of arbitrary precision numbers. Also 10000*100000 is too small dimensionality to encourage participants to make submissions of O((N + M) * log(N + M)) solutions due to high constant factor of latter. Stupid algorithm with randomization and trivial vectorization is faster (and extremely easier to implement) then clever algorithm with Voronoi and point location. |
| Why this DP solution doesnt work? | Dmitriy | 1353. Milliard Vasya's Function | 13 Feb 2018 06:22 | 8 |
I thought that this problem is so easy. After many tries to solve that I should say: that is not so easy and I cant solve it! Please, if you DP-master tell me where I'm wrong. So, the state is dp[sum][length] += dp[sum - digit][length - 1], for each digit 0..9. The base is dp[1..9][1] = 1. I've got WA#10: My program for 10 output: 43756 (correct answer: 43749) I can't find a little bug ;( [code] for s := 1; s <= S; s++ { for l := 2; l <= 9; l++ { for d := 0; d < 10 && s - d > 0; d++ { if dp[s - d][l - 1] == 0 { continue } dp[s][l] += dp[s - d][l - 1] if d == 0 { dp[s][l]++ } } } } [/code] You don't need to store previous positions: for (int position = 2; position <= 9; position++) for (int sum = 81; sum > 0; sum--) for (int digit = 1; digit <= 9; digit++) if (sum >= digit) ways[sum] += ways[sum - digit]; because you have to start l at one and eliminate continue and s - d >= 0 No. You are wrong here. I've found my error, it was a dp base. Thx for all. Guys, what are you doing in New Year? Hahaha |