|
|
Common BoardCan anyone write for me test 18, plz? Any help would be appreciate! what is test 22? i wa 22 what's wrong? #include<stdio.h> #include<string.h> int n,p,a[1000010],min=1000000,max=0,sum=0,ans=0; int main() { int i,x,j,k; memset(a,0,sizeof(a)); scanf("%d%d",&n,&p); for(i=1; i<=n; i++) { scanf("%d",&x); a[x]++; if(x<min) min=x; if(x>max) max=x; } for(i=min; i<=max; i++) if(a[i]!=0) { if(a[i]*i>=p) break; sum+=a[i]; ans++; } for(k=min; k<i; k++) if(a[k]!=0){ for(j=k+1; j<i; j++) if(a[j]!=0) break; if(a[j]==0) break; if(j*(a[k]+a[j])<p) { ans--; a[j]+=a[k]; a[k]=0; } } printf("%d %d\n",sum,ans); return 0; } Edited by author 10.03.2013 08:41 呃…… Edited by author 10.03.2013 08:48 Edited by author 10.03.2013 08:48 you can cast a spell with power of p Hello i wrote the following code in python , but it takes too much time, hwo should it be improved class timus1073: def __init__(self): pass def problem(self,y): a = [0] + range(1,60001) b = [x**2 for x in range(1,246)] for i in b: j = 0 while j+i <= 60000: if (a[j+i] > a[j] + 1): a[j+i] = a[j] + 1 j = j + 1 return a[y] if __name__ == "__main__": p = timus1073() a = input() print p.problem(int(a)) test #2 include 1,when you input 1,you will output 2 not 1 Пример исходные данные результат 3 2 3 ||| - 3 бифштекса, 2 на одной сковороде || - 2 минуты | - 2 минуты итого 4 минуты, а не 3 Please read down the forum.. 12 23 13 их можно недожареные убирать потом опять ложить чтобы всегда на сковороде лежало з штуки! Подумай над этим Как? Если количество месть на сковороде 2 как ты туда одновременно положишь 3? вы че считать не умеете? how u can put third Steak if you can put only 2? Where is the Logic? А все я понял! Но все равно ты не правильно объясняешь!) А другим объяснить видимо нельзя,спасибо. Первая минута: 1 сторона 1-ого Б. , 1 сторона 2-ого Б. Вторая минута: 2 сторона 1-ого Б. , 1 сторона 3-ого Б.(первый готов) Третья минута: 2 сторона 2-ого Б. , 2 сторона 3-ого Б.(второй и третий готов) New tests were added. 123 authors lost AC after rejudge. Which is strange, since everything else is allowed in output. em test thử tren visual 2010 ra kết quả nhung khi nop len acm toan in ra cau tra loi sai without round function i got WA #14. When i used it i got AC! #include <iostream> #include <cmath> using namespace std; double round(double d); int main() {double P, Q; #ifndef ONLINE_JUDGE freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #endif cin>>P>>Q; P/=100; Q/=100; int i=2; while(true) {double min=round(i*P); double max=round(i*Q); int C=int(max); if(C>min && C<max && C>=1) break; i++; } cout<<i; return 0; } //--------------------------------------------------------------------------- double round(double d) {return floor(d*10000+0.5)/10000; } Done :) Edited by author 19.07.2011 09:10 If you get WA# 14 this test maybe help you: 2 0 1 1 0 1 1 2 1 answer: YES 1 4 2 3 First of all, it should be noted that in the literature such problem is known as "bottleneck multiple subset sum problem" (B-MSSP) and it's a variation of knapsack problem. This problem even with such restrictions is an NP-complete. So, the aproximate solution even needed. Precision??? The precision is mystic (based on statement of the problem). I don't know how other people solved this problem, but I aproximate solution through aproximation of every pair of subsets. To aproximate a pair of subsets we need to solve B-MSSP just for 2 subsets. This can be solved in O( (|S1|+|S2|)*max(Ai) ) time and O( max(Ai, |S1|+|S2|) ) space complexity. hi can you please show / send me some hint about test #2 ? (I think you can see the source code of my attempt) p519446 at yandex.ru TIA. I am learning python. When i see the example of problem 1000 and 1001, python reads from stdin. How can i read from input.txt without changing my program every time i send it in. e.g. pascal uses #ifdef online_judge to read from files In linux I prefer to use this command: xclip -out | python problem.py It takes input from clipboard and send it to script. I use Windows on my computer. When i define a function like def invoer(place): if place=='file': f = open('input.txt', 'r') regel=f.readline() print(sum(int(x) for x in regel.split(' '))) f.close() else: print(sum(int(x) for x in input().split(' '))) invoer('console') I can use a file. Is there a smarter way? hi all I'm interesting on praxis to solve tasks using java threads. Do we have here such ones ? Many thanks to author of this task and Oleg Strekalovsky [Vologda SPU] for the hint ( http://acm.timus.ru/forum/thread.aspx?id=22536&upd=634614144741133716 ). PS. It is very unexpectedly to me that some collection types (e.g. HashMap) take so much memory and CPU time in java :-/ Edited by author 19.04.2013 22:14 Edited by author 19.04.2013 22:14What the hell is test 9? In my computer I got 0.06s in worst case but still TLE 9! |
|
|