This repository was archived by the owner on Feb 29, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +10
-4
lines changed Expand file tree Collapse file tree 3 files changed +10
-4
lines changed Original file line number Diff line number Diff line change 1- 8
1+ -1
Original file line number Diff line number Diff line change 77public class angry {
88 static List <Integer > field = new ArrayList <Integer >();
99 public static int N ;
10+
1011 public static int launchSim (int power ){
1112 int cowsUsed = 0 ;
1213 int curCow = 0 ;
14+ // /int lastCow = field.get(field.size() - 1);
1315 while (curCow < N ) {
1416 int pos = field .get (curCow );
1517 curCow ++;
1618 for (int i = pos ; i < N ; i ++) {
17- if (pos ) {
19+ if (field . get ( i ) < pos + 2 * power ) {
1820 curCow ++;
1921 }
2022 }
23+ cowsUsed ++;
2124 }
2225 return cowsUsed ;
2326 }
@@ -37,7 +40,7 @@ public static void main(String[] args) throws IOException{
3740 int r = N ;
3841 while (r - l > 1 ) {
3942 int m = (l + r ) / 2 ;
40- if (launchSim (m ) < K ) {
43+ if (launchSim (m ) > K ) {
4144 r = m ;
4245 } else {
4346 l = m ;
@@ -46,10 +49,13 @@ public static void main(String[] args) throws IOException{
4649
4750 System .out .println (field );
4851 //System.out.println(costs);
49-
52+ System . out . println ( l + " " + r );
5053 PrintWriter pw = new PrintWriter (new BufferedWriter (new FileWriter ("angry.out" )));
5154 pw .println (answer );
5255 pw .close ();
56+ for (int i = 0 ; i < N ; i ++) {
57+ System .out .println (i +": " +launchSim (N ));
58+ }
5359 //System.out.println("");
5460 }
5561
You can’t perform that action at this time.
0 commit comments