|
|
Show all threads Hide all threads Show all messages Hide all messages | to admin for input description | Ade | 1838. Samurai's Stroke | 2 Jun 2023 14:56 | 1 | "The second line contains n different positive integers, which are less than the L", That's result translated from RUS version. But the ENG version has not the word "positive". Please can you take a look? | beautiful problem | Aneto | 1838. Samurai's Stroke | 10 Jul 2012 16:30 | 1 | just wanted to thank the author | Samurai's Stroke | nvnp | 1838. Samurai's Stroke | 13 May 2011 17:32 | 6 | Can the prop be at the end of the stick ? Isn't it always length of stick for n=2 and n=3 ? Did i understand the question correctly ? This was giving WA. v[0]=0; int leftend=(v[1]-v[0])*2; int rightstart=len- ((len-v[n])*2); // 0 to leftend ,closest v[i]; // rightstart to len closest[j]; // // for(i=1;i<=n;i++){ if(leftend<=v[i]) { leftend=v[i];break; } } for(i=n;i>=1;i--){ if(rightstart>=v[i]) { rightstart=v[i];break; } } printf("%d\n",len-((rightstart-leftend)<0?0:((rightstart-leftend)))); every remaining peace should be remin at least at two props, so, for n < 4, there no possible place to stroke (result = l) Similar you can to ignore the part from 0 to v[2] and from v[n - 1] to l prop can not be at the end of the stick, but it can be at strike-point (at end of remaining part) You need to look all interval between v[i] and v[i + 1] for i in 2..(n-2) to find summ of strike-proof places, remaining part will fall, either outside (if strike too close to prop) or inside (if strike too far). So between every props there is only strike-proof interval. Excuse my English :) Can you give an example ? I understand that Gennosuke cuts only once. An example would help a lot. I understood as follows We have props at 1 2 3 4 0 1 2 3 4 5 [START]..v[1]..v[2].v[3]...[vn] XXXXXX[LEN] now since the left overlang is v[1], for the center of mass to lie between 2 props the closest prop should >=2*v[1] and for the right overlang the center of mass to lie , it should be (len -v[n])*2 , so the closest prop <(len-v[n])*2 . We paint the overhang to these props. for example 10 4 2 3 7 8 we can't strike at left of 3, because left part will have only 1 prop and will fall down like this we can't strike at right of 7 so, consider interval 3...7 at position less than 4 - left part of stick will fall down to left (because it's center of mass left-of first prop at position 2) at position more than 6 - left part will fall to right, also for right-part. We can find the only interval we can use - it from 4 thru 6 So, we shall paint 10 - (6 - 4) = 8 Edited by author 01.05.2011 02:08 Can you give an example why we need to summuation of each interval and why we need to round it up ? I think it will always be an integer. This gives me WA on test 7. for(i=1;i<=n;i++) scanf(" %d",&arr[i]); arr[i+1]=len; /* * v0,v1,v2,v3,v4,v5,v6 */ int lovr = arr[1] ; int rovr = len - arr[n] ; int tot = 2*lovr + 2*rovr ; int rmax=0,lmax; for(i=n-1;i>=1;i--) { if( ( arr[n] - arr[i] ) > rovr ) { if(i==n-1) { rmax=len-arr[i]; } else { rmax=2*rovr; } break; } } for(i=2;i<=n;i++) { if((arr[i]-arr[1]) > lovr) { if(i==2){ lmax=arr[i]; } else { lmax=2*lovr; } break; } } if(lmax + rmax > len) printf("%d\n",len); else if(tot > len) printf("%d\n",len); else printf("%d\n",rmax+lmax); Edited by author 13.05.2011 16:36 try this 13 6 1 2 6 7 11 12 result 8 | test | Ronnie | 1838. Samurai's Stroke | 30 Apr 2011 16:26 | 2 | test Ronnie 30 Apr 2011 13:46 what's the answer for this? 5 2 0 5 if we cut anywhere, the centre of mass will be between two props, but i think it should fall. so is it 0 or 5? The test is incorrect. Because props can't stay on 0. Only >0. Sorry for bad english. | WTF????? | Viktor | 1838. Samurai's Stroke | 30 Apr 2011 14:22 | 2 | WTF is this problem about o.O |
|
|
|