Problem link : http://codeforces.com/problemset/problem/716/A
Rather than actually implementing the word typing simulation, I simulated it from the end. That way, as soon as I find out that the delay between words typed is larger than c, I can break out of the loop and print the answer
Problem link : http://codeforces.com/problemset/problem/237/A
Cash refers to money in the physical form of currency, such as banknotes and coins. – Wikipedia
How does money serve people ? I don’t know.
The problem simply needs us to count max number of customers coming to the cafe at the same time. I used a simple array to store it by multiplying hours with 100 , then adding minutes to it as the index.
Problem link : http://codeforces.com/problemset/problem/570/A
Direct Implementation, do what the problem tells you to do straight. No tricks on this one, except that indices starts from 1 , not 0.
Simply get the winner from each city, increment their final score, and finally find the candidate with highest score and lowest index ( in case if there are candidates with same final score)
This one’s pretty simple. However at first I thought I need to use [su_highlight background=”#feb0c1″]long[/su_highlight] instead of [su_highlight background=”#feb0c1″]int[/su_highlight] since the number of votes can be as high as 109. But then I realized that 109 is the highest value it can be, so [su_highlight background=”#feb0c1″]int[/su_highlight] would suffice
Problem link : http://codeforces.com/problemset/problem/514/A
I guess this counts as implementation. I simply scan the number as a string, and flip them if their value is greater than 4 (the flipped value will be lower than 5, ensuring that we will get minimum value), with exception if the first number is equal to 9, don’t flip it since it will produce a leading zero.
Nothing special on this problem. It’s pretty simple and straightforward.
Problem link : http://codeforces.com/problemset/problem/439/A
Another implementation. I simply add up all the time required for the performance and store them in a temporary variable (let’s call it T).
Then, I add (n – 1) * 10 minutes to T. 10 minutes is the time required for Devu to rest. He only needs (n – 1) rests since his final rest can be simply excluded from the concert time.
Then, I check whether T exceeds d . If it does, I simply set the answer to minus one (means that time d isn’t enough even if Churu cracks no joke)
We know that Devu will have n – 1 rests. Which means that Churu can crack (n – 1) * 2 jokes while Devu was resting. If d – T does not equal to zero, we must include number of jokes Churu can crack in the remainder time. We can simplify it as
extraJokes = (d – T) / 5
This problem was pretty simple. However I did make a mistake : I thought that Devu would have n rests. Luckily, the test cases provided by the problem would trip this error. So I guess that is a good thing.
Problem link : http://codeforces.com/problemset/problem/732/A
At first I was kinda confused, but in the end I opted for a simple brute force.
My initial idea was to create an array, mark arrays that is multiple of k with one and mark others with zero. Then iterate on each array, see if current array’s value is one, then whether we can form the index i with the coins. But I realized that there’s no need to store anything, so I simply iterate the multiple of k (We’ll call this k’) , see if we can be divide k’ by ten, or if the result of k’ % 10 equals to r.
Why ? We are allowed to use any combination of coins, so if ten coins can form value of k’, we reach our goal already. But if we can’t, we try adding r to the value and see if it forms k’. If we can’t form current k’, we advance by adding k to k’ until we find the right k’.
I’m still wondering if there’s a quicker way to solve this. I had something like instead of bruteforcing multiplies of k, what if we iterate on the amounts formed by ten coins and r instead ? But that I scrapped that idea since we’ll have to multiply k if the current k’ value surpasses current k’. I guess the way above works for now.
Problem link : http://codeforces.com/problemset/problem/467/B
This problem was quite straightforward. The question states that a positive integer represents player’s army, and the binary representation of the integer tells us which troop types the player has. To find the answer, we compare Fedor’s army and all other players’ army to determine how many troop types differences are there, and from that determine if the player can be Fedor’s friend, finally count how many players can be his friend.
At first I was lazy, so I simply scanned all the numbers, directly XOR them with Fedor’s number, then count number of 1 bits manually.
And boom. TLE.
So I tried storing the numbers in form of bitset<32>. The rest is still the same. XOR them, get remaining number of 1 bits ( but this time I’m using bitset’s count() ) and boom. Accepted.
I’m still bit confused until now. I’m not sure which part fixed the TLE thing. Maybe bitset XOR is faster than integer XOR. Or maybe bitset’s count() is waay faster than
While number is not 0, modulus it by 2, append the remainder, divide it by 2, rinse and repeat
I tried __builtin_popcount() but it didn’t help with the TLE. So bitset’s count() must be blazing fast.
“coding is fun”
“only if you managed to get an AC”
Well, it’s not like I’m a good writer in the first place.
A blog ? hell. I fill mine with my ramblings, and swears, and cookies. I love cookies.
Look at my friends for a good example, they fill their blogs with good contents, such as wise words, story that will make you reconsider your pity existence in midst of this frickin’ world, or maybe some tutorials about things you study, like programming , designing, etc. Or, if you’re not that google adsense savvy, you can put *cough* PIRATED STUFF on yer blog.
But yeah, life’s a bitch. Coz she teaches everything the hard way.
For example, Yesterday I tried to install Ubuntu on my laptop.
Guess what ? Hell broke loose. I accidentally deleted the partition with my windows on it.
Well, I thought that I won’t need windows if I’m not going to play games anymore. Ah, almost forgot. I decided to quit playing games a few weeks back.
But nah, ubuntu ran smoothly only for the first time. The second time ? errors. Tried to use liveCD, error log said HDD is dying. Seriously ? This crap had its HDD replaced few years ago.
Are all HDDs that weak ? Look at that frickin’ nokia, man.
I also tried to check HDD status with my BIOS. My Laptop’s HP Pavilion DV6. and I got error 303. What does it mean ? You guess.
Of course, you HDD is gonna fail yadda yadda yadda. I tried to reinstall ubuntu. guess what ? the HDD fake failure is blocking everything.
So I tried to download Windows 8 . My uni gave me a free one, and another 8.1 But i decided to get the 8 one BECAUSE MY ACCOUNT IS FRICKIN’ EXPIRED AND THE ADMIN REFUSED TO EXTEND MY FRICKIN’ ELIGIBILITY !
But I can still get the 8 one though, I ordered it a year ago.
Tried to use SecureDownloadManag0rz <- shit, AND I REACHED 99% 3 FRICKIN' TIMES TO HAVE THE SOFTWARE TELLING ME I HAVE TO REDOWNLOAD ALL THOSE CRAP COZ OF FAILURE OF YADDA YADDA YADDA.
oh , shit. 4 times is a charm, not 3 times anymore. So yeah, I wasted 12GB value of time.
But it was worth it though, my laptop's now fine, Windows 8 took care of everything.
Makes me want to buy mac, I mean, if Windows are spoiling me like a 10 years old who just played chip's challenge for the first time, maybe Mac is a super intelligent being that gives babies a hack to win every game in the iPad.
It's so expensive tho. So it's a no-no.
And yes, holiday is a curse and a blessing. I played all day .
But my friends.
They study all day and now I feel like a Dinosaur from ancient age. Tried to catch up with them all, but I can't. I just can't make a good game design while trying to chomp down what Ruby is doing.