| Показать все ветки Спрятать все ветки Показать все сообщения Спрятать все сообщения |
| Got AC in O(|E|)!!!!! | cena | 1106. Две команды | 20 мар 2016 20:52 | 2 |
Is there any better solution? No. This is the lower bound, since you have to read the edges anyways. |
| Brute force;-) | Katy | 1126. Магнитные бури | 20 мар 2016 19:04 | 5 |
I know that this problem could be solved using sorting and something like that - my friends do so but don't share code, I don't know how. I used brute force (= the easiest way) and i got AC 0.281 330 KB at C++ You can use structure Heap or Interval Tree ( because the value of the elements is rather small ). Heap : O(NlogM) Interval tree : O(N log(Max_Value) ). Interval tree also can give you the k-th smallest value in log (Max_value). I know that this problem could be solved using sorting and something like that - my friends do so but don't share code, I don't know how. I used brute force (= the easiest way) and i got AC 0.281 330 KB at C++ Yes... and with little bit of optimization, one can get AC in half of that time... :) Edited by author 20.03.2016 19:06 |
| Hint | Jane Soboleva (SumNU) | 2070. Интересные числа | 20 мар 2016 15:53 | 8 |
Hint Jane Soboleva (SumNU) 22 окт 2015 02:04 Re: Hint Mikhail Krivenko 22 окт 2015 02:23 I implemented that but I have WA 5. What's in this test? Re: Hint Jane Soboleva (SumNU) 22 окт 2015 14:51 I don't know, maybe double check if your numbers are exactly in range of [a, b]? And if they're long, not int? Re: Hint Combatcook [YarSU] 🐸 19 мар 2016 18:59 I implemented it too, but still have WA 27... Please, help me found a bug... What's wrong here: -- Thanks in advance. Edited by author 19.03.2016 19:43 Edited by author 20.03.2016 15:53 Re: Hint Jane Soboleva (SumNU) 20 мар 2016 01:33 For max test, your answer ends in 3. But it's actually 8. Re: Hint Combatcook [YarSU] 🐸 20 мар 2016 14:27 Can you give the right answer on that test? Re: Hint Jane Soboleva (SumNU) 20 мар 2016 15:15 Uh, i just did? I guess i didn't make it clear enough. Anyways, there you go. 2 1000000000000 999999921288 UPD: it's fine, and congrats~ Edited by author 20.03.2016 16:06 Re: Hint Combatcook [YarSU] 🐸 20 мар 2016 15:53 Sorry for bother, I just wanted to clarify. :) Now I corrected a mistake and got AC. |
| if you have WA # 15 try this test cases | Adhambek | 1755. Торт | 19 мар 2016 17:06 | 2 |
input 1: 1 2 0 1 10 10 output 1: 10 5 input 2: 1 2 1 0 10 10 output 2: 5 10 input 3: 1 2 0 0 10 10 output 3: 10 10 Edited by author 17.12.2015 10:39 Thank you And it's really strange that in these three cases if I output 0 5 5 0 0 0 I will get a WA...., if I output the another answers I will get AC... why? |
| WA 21 | Stas | 1261. Чаевые | 19 мар 2016 13:35 | 1 |
WA 21 Stas 19 мар 2016 13:35 What is number N = ? and what to output? |
| Very good AC - 0.281 sec and 850K | 12345 | 1316. Биржа | 19 мар 2016 12:05 | 8 |
My program uses only 850K of memory!!! Two days of troubles and the best solution was written! If you are intrested in it leave your mail here. I've solved this problem via interval tree, but it uses 4 Mbytes. I don't need your code, but could you explain your algorithm? My e-mail is dimanyes@yahoo.com I think, that he have used Fenwick tree No :) This solution uses Cartesian tree. My best solution which uses Fenwick's tree uses about 1400K of memory PS: Good luck on the ROI, Ilya :) Can you say book's names where these tree are described? I've modified this solution... Now it uses only 630K of memory!!! (Random Trees are very useful :) can i do it without trees ? like this #include<iostream> #include<string> using namespace std; void limit_to_two_num(float &price) { price=price*100; price=static_cast<int>(price); price=(price)/100; } void main() { int check=0,quantity,length=0; string str="\0"; float price; float profit=0; float arr[100000]; while(str!="QUIT" && check!=100000) { cin>>str; if(str=="BID") { cin>>price; limit_to_two_num(price); arr[length++]=price; check++; } else if(str=="DEL") { cin>>price; limit_to_two_num(price); for(int i=0;i<length;i++) { if(arr[i]==price) { for(int j=i;j<length-1;j++) { arr[j]=arr[j+1]; } length--; break; } } check++; } else if(str=="SALE") { cin>>price; limit_to_two_num(price); cin>>quantity; for(int i=0;i<length;i++) { if(arr[i]>=price) { profit=profit+0.01; } } } } cout<<"Total profit: "<<profit<<endl; } i can't solve this problem.Please help... yu1178209138@hotmail.com |
| Strange Aeroplane | IlushaMax | 1893. A380 | 19 мар 2016 01:25 | 1 |
window | ******| window window?|****|window? The distance between window and last chairs is 1 chair but it's there! Windows can be only in Business and Econom cause these parts are in different decks. |
| Why access violation(pascal)? | IT | 1563. Баяны | 18 мар 2016 22:23 | 1 |
Edited by author 22.03.2016 20:56 Edited by author 22.03.2016 20:56 |
| Выдает ошибку "Runtime error 1" | Artem Alieinikov | 1005. Куча камней | 18 мар 2016 14:41 | 2 |
Можете обьяснить пожалуйста что я делаю не так? Я ходил по обсуждению задачи пробывал тесты которые предлагают, результаты вроде бы как правильные. Может я неправильно организовал ввод/вывод данных? Работает как-то так. Считываю в 1 строку: 6 1 4 5 6 7 9 Очищаю консоль и вывожу Console.WriteLine ответ: 0 There are 2 (TWO) lines in the sample. First contains count of stones, second contains stones weights. Your test should look like: --- 6 1 4 5 6 7 9 --- By the way some languages (C scanf/C++ iostream/Java scanners) allow reading from input without checking how data items are placed on input lines. Here - http://acm.timus.ru/help.aspx?topic=csharp - input read in similar way via string[] input = Console.In.ReadToEnd().Split( new char[] {' ', '\t', '\n', '\r'}, StringSplitOptions.RemoveEmptyEntries); |
| what is the so-called initial step for 2 eggs / 20 floors? | Михаил Аршинов | 1223. Chernobyl’ Eagle on a Roof | 18 мар 2016 03:06 | 10 |
spot check shows me that it should be 7 am i right? then the answer is 8 moves?? EGGS=2, FLOORS=20 (20 eggs, initial step = 7) e=20(20) 7 14 17 18 19 e=19(20) 7 14 17 18 19 (+7, +3) ...(e=18..14 ) e=13(20) 7 14 8 9 10 11 12 13 [7 moves] (20 eggs, initial step = 7) (20 eggs, initial step = 6) e=5(20) 6 1 2 3 4 5 e=17(20) 6 12 18 13 14 15 16 17 [8 moves] (20 eggs, initial step = 5) e=20(20) 5 10 15 18 19 20 e=17(20) 5 10 15 18 16 17 e=14(20) 5 10 15 11 12 13 14
(20 eggs, initial step = 4) 4 8 12 16 20 17 18 .. thanks! also what is the algorithm for this particular test case? thanks or maybe step is not fixed at all? like step0=7, step1=6, step2=5? +6 +5 +4 +3 6 11 15 18 5 6 1 2 3 4 5 10(or 11) 6 11 7 8 9 10 14(or 15) 6 11 15 12 13 14 17(or 18) 6 11 15 18 16 17 20 6 11 15 18 19 20 hmm for 2 eggs / 20 floors the answer is 6, this is weird Edited by author 16.03.2016 05:21 2eggs 100floors (14) +14 +13 +12 +11 +10 +9 +8 +7 14 27 39 41 52 62 71 80 88 95 39 14 27 39 28 29 30 31 32 33 34 35 36 37 38 100 14 27 39 41 52 62 71 80 88 95 96 97 98 99 IIRC for this task we need to save the last egg at all costs, until the moment we figure out the exact answer. For 2 eggs / 20 floors, that would be: 1st try: 6, and if breaks — 1, 2, 3, 4, 5 in worst case for last egg (so it breaks when we figure out the answer for sure). 2nd: 11, if breaks — 7, 8, 9, 10. 3rd: 14, if breaks — 11, 12, 13. 4th: 17, if breaks — 15, 16 5th: 19, if breaks — 18. 6th: 20 So in worst case, 6 tries. Then again, i didn't solve it yet, so i can't guarantee anything, but that's how i understood it from previous discussions. And yeah, you already described it above, i didn't read. Sorry. Edited by author 16.03.2016 06:26 the direction is right, step0 is the answer, for 2 eggs dunno for 3 eggs also coz i не решил еще тоже Well, intuitively, with 3 eggs we should put the first one in the middle, to minimize a floor quantity in worst case for remaining two eggs? intuitively this is DP problem with precomputing table of 1001x1001 cells row 1 contain values -1 1 2 3 4 5 .. row 2 contain values -1 1 2 2 3 3 .. row 3 ?? with 3 eggs we do move0 somewhere in the middle, doing loop from Eggs to 1, computing min(row1[step1]+row2[step22]) (or minimize step1+step2, maybe) for 3 eggs: for (step2=e; step2>1; step2--) for (step1=i2; step1>1; step1--) row 2 : -1 1 2 2 3 3 3 4 4 4 4 5 5 5 5 5 6 6 6 6 6 6 7 7 7 7 7 7 7 8 .. |
| WA 9 | Justine Tsiga | 1435. Финансовая ошибка | 17 мар 2016 22:05 | 1 |
WA 9 Justine Tsiga 17 мар 2016 22:05 Can you give me some examples, please! |
| how to make it right? | Bartenal | 2056. Стипендия | 17 мар 2016 15:35 | 1 |
n=int(input()) l=[int(input()) for _ in range(n)] items=sum(l) n=float(n) x=3.0 for i in l: try: i==x print ('None') if items/n==5 and i!=x: print 'Named'
elif (4.5<=(items/n)<5)and i!=x: print 'High'
elif ((items/n)<4.5)and i!=x: print 'Common' |
| If answer too big...clarification here | Drunken Statue | 1017. Лестницы | 17 мар 2016 14:11 | 1 |
Problem ambiguous but finally solve! I scratched head for longest time, so clarification here to help others Do not worry, no answer writed, only clarification: IMPORTANT 1: One step = one grid COLUMN. Example show 2 steps: * ** Example show 2 steps: * ** ** Example show 4 steps: * * * ** *** **** IMPORTANT 2: Step HEIGHT > before step height. Example show all VALID N = 7: VALID Staircase #1 of 4 * * * * * ** VALID Staircase #2 of 4 * * * ** ** VALID Staircase #3 of 4 * ** ** ** VALID Staircase #4 of 4 * * ** *** Example of INVALID N = 7: INVALID Staircase: * * * * * * * Invalid because only 1 step INVALID Staircase: * *** *** Invalid because 2 steps same height (height 2, height 2, height 3) INVALID Staircase: * * * * *** Invalid because step height not > before step (height 3, height 1, height 3) |
| If you have WA #14 | Smilodon_am [Obninsk INPE] | 1998. Старый падаван | 17 мар 2016 01:34 | 4 |
try this test: 10 1 10 100 9 1 1 1 1 1 1 1 1 10 right answer: 19 Edited by author 10.11.2013 14:51 Edited by author 10.11.2013 14:51 Edited by author 10.11.2013 14:51 You can try this .... 5 1 4 1 2 2 6 6 5 right ans : 7 |
| The solution is correct but test1 says it's wrong :/ | Arusyak | 1493. В одном шаге от счастья | 16 мар 2016 20:31 | 2 |
//Timus1493 #include <iostream> using namespace std; //Creates a copy and does not change the argument int sum_of_3(int num) { int result = 0;
for (int i = 1; i <= 3; i++) { result += num % 10; num /= 10; } return result; } int main () { int num; cin >> num;
int digit = num % 10, right = sum_of_3(num), left = sum_of_3(num / 1000);
if ((left > right && digit == 9) || (left < right && digit == 0)) cout << "No \n"; else cout << "Yes \n"; cout << num; return 0; } Fix output as task required - remove spaces after Yes and No, remove "cout << num;". |
| Why WA1??? | sirenko.anas | 1026. Вопросы и ответы | 16 мар 2016 19:21 | 1 |
program z1026; var n,k,i,j,nomer:integer; count:array[1..5000]of integer; a,rez:array[1..100000]of integer; z:array[1..100]of integer; s:string; begin read(n); for i:=1 to n do read(a[i]); read(s); read(k);
for i:=1 to 5000 do count[i]:=0; for i:=1 to n do inc(count[a[i]]); nomer:=1; for i:=1 to 5000 do for j:=1 to count[i] do begin rez[nomer]:=i; inc(nomer); end; for i:=1 to k do read(z[i]); for i:=1 to k do writeln(rez[z[i]]); end. Answer for test1 is 121 121 7 123 |
| if input=800,100168 what's the output? | gc007 | 1189. Pairs of Integers | 16 мар 2016 19:03 | 3 |
800 5 725 + 75 = 800 728 + 72 = 800 730 + 70 = 800 750 + 50 = 800 800 + 00 = 800 100168 8 90584 + 9584 = 100168 91034 + 9134 = 100168 91059 + 9109 = 100168 91062 + 9106 = 100168 91064 + 9104 = 100168 91084 + 9084 = 100168 95084 + 5084 = 100168 100084 + 00084 = 100168 |
| Машинное обучение и анализ данных | Academic | | 16 мар 2016 19:03 | 1 |
Владение информацией и умение ее анализировать – главная и наиболее востребованная задача сегодня. Спрос на специалистов, умеющих работать с «большими данными » растет с каждым годом, а профессия Data Scientist становится одной из самых популярных в мире. В сжатом и компактном виде нужная информация сегодня доступна в формате онлайн обучения. Так, ведущие умы МФТИ и практики Яндекса объединили свои знания, чтобы запустить специализацию «Машинное обучение и анализ данных» на базе образовательной платформы Сoursera. Если у вас есть непреодолимое желание заняться этим, открыть для себя новые карьерные возможности, МФТИ и Yandex Data Factory предлагает присоединится к дистанционному обучению по специализации «Машинное обучение и анализ данных» . Подробности и особенности курса в профиле проекта на Coursera https://www.coursera.org/specializations/machine-learning-data-analysis |
| WA5 | DarkMaar | 1998. Старый падаван | 16 мар 2016 15:44 | 1 |
WA5 DarkMaar 16 мар 2016 15:44 As usual cannot find a mistake in my code. Program prints right answers on all user's tests in this discussion, however WA5 is still here. UPD: oh, just should give test like '1 1 1 1 0' Edited by author 16.03.2016 16:17 |
| Почему WA7? | JamesBond_007 | 1306. Медиана последовательности | 16 мар 2016 14:40 | 2 |
#include <iostream> #include <algorithm> #include <math.h> #include <string.h> #include <stdio.h> using namespace std; unsigned int a[150002],k,kk,n,q,i; int main() { cin >> n; if(n > 150000){ k = n - 150000; n = 150000; } for(i = 1;i < n+1; i ++){ cin >> a[i]; } sort(a,a+n+1); for(i = 1; i <= k; i ++){ cin >> q; if(a[n] > q) a[i] = q; } if(k > 0) sort(a,a+n+1); if((n + k) % 2 == 1){ cout << a[ n / 2 + 1 - k]<< endl; }else { kk = a[n / 2 - k] % 2 + a[n / 2 + 1 - k] % 2; cout << (1ll * a[n / 2 - k] + a[n / 2 + 1 - k]) / 2; if(kk == 1)cout << ".5"; } } Sorry, was wrong. Edited by author 17.03.2016 14:29 |