Общий форумMy solution of 1005 problem was accepted. Here it is: #include <iostream> #include <vector> #include <algorithm> using namespace std; int main(){ int n,t; vector<int> w; cin >> n; for(int i = 0; i < n; ++i) { cin >> t; w.push_back(t); } sort(w.begin(), w.end()); vector<int>::reverse_iterator it = w.rbegin(); vector<int>::reverse_iterator end = w.rend(); int s = 0; for(; it != end; ++it) s += *it; it = w.rbegin(); s = s/2 + (s%2); int l = 0, r = 0; for(; it != end; ++it) if(l + *it <= s) l += *it; else r += *it; cout << abs(l-r) << endl; return 0; } But there is a test, where this solution gives a wrong answer: 6 101 51 51 3 2 2 Yeah, right answer is 0, but your 2.. I hope that admins will add some new tests. Edited by author 11.08.2012 20:16 what answer for this test: 0 0 1 0 1 1 2 1 0 or -1 ? 0, cause a line doesn't have the area. Run the program on this test: n = 50000 0 1 1 1 2 1 ... i i+1 1 ... 50000-2 50000-1 1 m = 1 0 1 Edited by author 14.12.2012 05:58 Edited by author 14.12.2012 05:58 f2ba8f04-8e51-4a98-89b6-0170582bbb1b(21) : error C3861: 'getline': identifier not found but in the sample (in the FAQ) getline method is used I have similar problem, my code is compiled well on my home PC (MS VC++ 2010), but the same code getting compilation error on Timus. Let me present here a fragment of my code (All problem-related part was expunged, only variable declaration-initialization and input remained). This is also a compilable code on my PC. Can you consider it please. Thanks in advance. #pragma comment(linker, "/STACK:5000000") #include <iostream> using namespace std; int main() { char tmp, *or, *samp; or = new char[250001]; samp = new char[750002]; int N, z[750002]; memset(&z[0], 0, 750002*4); scanf("%i", &N); scanf("%c", &tmp); cin.getline(or, 250001); cin.getline(samp, 750002); return 0; } P.S. Adding "#include <string>" didn't helped. Edited by author 13.12.2012 21:44 somebody help me!!!!! i get crash(integer division by zero) at test#1!!!!!!! wtf is this test case?? "integer division by zero" i don't see anywhere i divided a number by zero!! In some discussions people give tests with the precise test number, but I couldn't find tests of any exercices in main site and in problem exposition, so my question is: Where can I find timus' tests? Are there in some place or people got them in other ways? Thank in advance. People who give tests don't surely know their numbers. The scheme is as follows: We write our solution on some problem, submit it and for example get verdict "Wrong Answer 5". Then we try to test our solution on tests, which we generate "at home". If we find such test on which our solution gives wrong answer, we fix mistake in program and submit it again. If new verdict is "Accepted" or for example "Wrong Answer 8", we will understand that Test 5 could be the same or similar like our. Thanks a lot, I've finally understood how it works. Check that all of arrays in your source less that 64 KB! (MS VC compiler limitation) help me! use only ''while not eof'' #include <cstdio> #include <map> std :: map<int, int> a; int ans = 0, n, c; int main() { while (scanf("%d", &n) == 1) for (; n; n--) scanf("%d", &c), ans += ++a[c] == 3; printf("%d", ans); } Edited by author 05.11.2011 20:31 can you explain the function/name "map" ? which language used in code above? map is in C++ STL and it is like a binary search tree. my program work. but timus don't accept answer. var n,k,m:word; begin read(n,k); if 2*n mod k=0 then m:=2*n div k else m:=(2*n div k)+1; write(m); end. K can be greater than N why is this take wrong answer? var n,k,m:word; begin read(n,k); if n>k then if 2*n mod k=0 then m:=2*n div k else m:=(2*n div k)+1; if n<= k then m:=2*n; write(m); end. When k >= n then we can cook all of them in two minutes (first minute one side, second minute second side) not in 2*n minutes. Edited by author 23.09.2011 20:06 Thank you!!!! I did it!!! why if 2n div k <> 0 you add 1? So i watch for cases when point a is the same with point b, when they are reversed, when b = a = kozel and when rope is longer then distance to the plant Could you give me some tests? var n,i,j,ans:Integer; k:integer; kvoskl:string; begin ans:=1; j:=1; read(n,kvoskl); k:=length(kvoskl); i:=n; if n mod k = 0 then begin while i>=k do begin ans:=ans*i; i:=n-j*k; inc(j); end; end else begin while i>=n mod k do begin ans:=ans*i; i:=n-j*k; inc(j); end; end; writeln(ans); end. what`s wrong? what's wrong with this site?? it's about 36 hours that all problems have waiting status. Sorry, due to hardware problem we have to stop judging at least until tomorrow. You may continue to submit your solutions, they will be judged as soon as the problem is fixed. Looks like hardware problems are resolved now. Judgement system is working in its usual mode. Have fun! What's happened to the system? I ask the same question. Already more than 200 people are waiting for testing... We have hardware problem. It will be fixed ASAP. Judging is working. But it will work very slow in the next few days. It broke again Sorry, due to hardware problem we have to stop judging at least until tomorrow. You may continue to submit your solutions, they will be judged as soon as the problem is fixed. Looks like hardware problems are resolved now. Judgement system is working in its usual mode. Have fun! I'm happy that i solved it! I'm think it is a basis of programming, that's why I'm happy! There is no english.. only runglish.. I'm Sorry for this, but it is so cool! Just use Greedy algorithm =) > Just use Greedy algorithm =) Greedy is wrong for this problem. uses SysUtils; var x:array [1..150000] of real; size,i:integer; n:double; begin size:=0; while not seekeof do begin read(n); inc(size); x[size] := sqrt(n); end; for i:=size downto 1 do writeln(x[i]:0:4); readln; readln; readln; end. var N,X:integer; begin readln(N); if N>0 then X:=round((1+N)*N/2); if N<0 then X:=round((1+N)*(abs(N)+2)/2); writeln(X); end. попробуйте ввести 0 оно выводит 0 хотя от 0 до 1 если включительно то ответ должен быть 1 Edited by author 10.12.2012 01:14 I have correct answer on PC and wrong - here?Why? |
|