This discussion board is a place to discuss our Daily Challenges and the math and science
related to those challenges. Explanations are more than just a solution — they should
explain the steps and thinking strategies that you used to obtain the solution. Comments
should further the discussion of math and science.
When posting on Brilliant:
Use the emojis to react to an explanation, whether you're congratulating a job well done , or just really confused .
Ask specific questions about the challenge or the steps in somebody's explanation. Well-posed questions can add a lot to the discussion, but posting "I don't understand!" doesn't help anyone.
Try to contribute something new to the discussion, whether it is an extension, generalization or other idea related to the challenge.
Stay on topic — we're all here to learn more about math and science, not to hear about your favorite get-rich-quick scheme or current world events.
Markdown
Appears as
*italics* or _italics_
italics
**bold** or __bold__
bold
- bulleted - list
bulleted
list
1. numbered 2. list
numbered
list
Note: you must add a full line of space before and after lists for them to show up correctly
I did silver.
1. I use DP (not actual DP) but it is more likely a binary search.
2. I use priorityqueue structure data, 2 looping (beginning->end, end->beginning)
3. I use 2 states DP (positionnow,position_last). Again, 2 times (beginning->end, end->beginning)
Good job! You probably did the same thing on #2 as me.
Yeah, I was sitting around eating dinner in the last hour. I should have fixed those cases in #1 where N<5 (2 and 3) and I might have been able to improve #3.
If I missed one more case, I would not have gotten promoted, whew!
import java.util.Scanner;
import java.util.ArrayList;
import java.util.Collections;
import java.io.File;
import java.io.IOException;
import java.io.PrintWriter;
public class milktemp{
public static void main(String[] args) throws IOException{
Scanner s = new Scanner(new File("milktemp (2).in"));
long start = System.nanoTime();
int n = s.nextInt(),
x = s.nextInt(),
y = s.nextInt(),
z = s.nextInt();
s.nextLine();
ArrayList<cow> cows = new ArrayList<cow>();
for(int i = 0; i < n; i++){
cows.add(new cow(s.nextInt(),s.nextInt()));
s.nextLine();
}
s.close();
Collections.sort(cows);
int max = 0;
for(int i = 0; i < cows.size(); i++){
int temp = cows.get(i).a,
total = (cows.size()-i-1)*x+y,
j = 0;
for(; j < i; j++)
if(cows.get(j).b < temp)
total += z;
else
total += y;
if(total > max)
max = total;
}
PrintWriter p = new PrintWriter(new File("milktemp.out"));
System.out.println(max + " - " + (System.nanoTime()-start));
p.close();
}
}
class cow implements Comparable<cow>{
public int a, b;
public cow(int a, int b){
this.a = a;
this.b = b;
}
public int compareTo(cow c){
if(a > c.a) return 1;
else if(a < c.a) return -1;
return 0;
}
}
Easy Math Editor
This discussion board is a place to discuss our Daily Challenges and the math and science related to those challenges. Explanations are more than just a solution — they should explain the steps and thinking strategies that you used to obtain the solution. Comments should further the discussion of math and science.
When posting on Brilliant:
*italics*
or_italics_
**bold**
or__bold__
paragraph 1
paragraph 2
[example link](https://brilliant.org)
> This is a quote
\(
...\)
or\[
...\]
to ensure proper formatting.2 \times 3
2^{34}
a_{i-1}
\frac{2}{3}
\sqrt{2}
\sum_{i=1}^3
\sin \theta
\boxed{123}
Comments
Another question: Which language did you use? Let's keep a tally in our posts (reply only to this one!)
Python: 1
C:
C++:
Pascal:
Java:
Log in to reply
Python: 2
C:
C++:
Pascal:
Java:
I'm learning C++ now.
Log in to reply
Python: 2
C:
C++:
Pascal:
Java: 1
Log in to reply
C:
C++:
Pascal:
Java: 2
C++++, but they post linguistic stats after each competition
Can somebody please post these problems? I
Log in to reply
Here
Log in to reply
Thanks! :)
i did bronze. #1 (combo) was trivial, #2 (milktemp) i brute forced, #3 i didn't really try. as you can see I'm really bad at programming.
Log in to reply
I also did bronze. #1 was easy, like you said; #2 I also brute forced but later I was shown a better sol; #3 I found a good solution to.
Log in to reply
I'm sorta surprised you guys didn't try #3; what did you find hard about it? Organizing the adjective strings? Efficiency?
Log in to reply
Log in to reply
eh maybe there is i kind of forgot the problem
Ah shoot, I messed up on #1 because I assumed things that made the problem too easy. 400 is okay; maybe next time!
I did silver. 1. I use DP (not actual DP) but it is more likely a binary search. 2. I use priorityqueue structure data, 2 looping (beginning->end, end->beginning) 3. I use 2 states DP (positionnow,position_last). Again, 2 times (beginning->end, end->beginning)
Anyone did the silver?
Yay results!
I got 667 in Bronze (yay promotion).
1: I hoped I would get it perfect, but failed tests 2 and 3 darn.
2: I thought I might get it perfect, but timed out tests 9 and 10.
3: I knew I would timeout later cases and get earlier ones, but I wonder why I failed test 4.
Also, I used java.
Log in to reply
Congrats! I got 800 in bronze because 6 of the 30 programs timed out. I should've been more efficient on my #3, I had all the time in the world! >:O
Log in to reply
Good job! You probably did the same thing on #2 as me.
Yeah, I was sitting around eating dinner in the last hour. I should have fixed those cases in #1 where N<5 (2 and 3) and I might have been able to improve #3.
If I missed one more case, I would not have gotten promoted, whew!
Bronze #1 (derp, I thought about PIE but I thought it would be too complex) (OOP FTW):
Bronze #2:
Bronze #3 (observation: the optimal temperature would be at least one cow's lower temperature):
Log in to reply
I think your observation was for #2.
http://www.expert5th.in/packers-and-movers-bangalore/
Bronze. 1 was trivial. 2 was easy if I didn't spend 1 hour doodling. I didn't have time to attempt 3. Overall, a disappointing performance.
Log in to reply
I only solved #1. :'(
http://www.expert5th.in/packers-and-movers-pune/
http://www.expert5th.in/packers-and-movers-bangalore/
http://www.expert5th.in/packers-and-movers-pune/