Archive for the ‘Uncategorized’ Category

INOI 2012 Triathlon problem [EDITORIAL]

Tuesday, June 27th, 2017

This problem featured in the Indian National Olympiad on Informatics in 2012. This problem is supposed to be of intermediate difficulty.
https://www.codechef.com/IOIPRAC/problems/INOI1201

The problem asks you to find out what is the minimum time in which the contest can be completed if you get to choose the order in which the participants start and given the times they take to complete each of the three tasks. Keep in mind that each task can only be completed if the previous task is completed before it.

There are a few observations to be made before we start solving this problem.

First of all the second and third tasks can be merged into one as they will be performed concurrently and sequentially by all the participants as soon as they have finished their first task.
d[i] = b[i] + c[i]
Where b[i] and c[i] are the times taken to complete the second and third tasks.

Now secondly, we need to decide in which order the participants will start. Think of it two at a time. What decides Person A will go before Person B given both their timing for the tasks ?

Assume Person A goes first and calculate the maximum time it will take. Now calculate it when Person B goes first. After some tedious analysis. It turns out that the person with the larger d[i] should go first. intuitively, it can be said that he will take a longer time to complete the second task and hence has to start it earlier. To do that he has to go first.

Now all we have to do is sort based on d values and let the contest proceed in that order. Calculate the end time of the contest and output it.

Java Code :
import java.awt.Point;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Comparator;
import java.util.StringTokenizer;

public class Main {
public static void main(String[] args) throws NumberFormatException, IOException {

BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

StringTokenizer st;
int N = Integer.parseInt(br.readLine());
int tim = 0;
Point p[] = new Point[N];
int ar[] = new int[N];
for (int i = 0; i < N; i++) { p[i] = new Point(); st = new StringTokenizer(br.readLine()); p[i].x = Integer.parseInt(st.nextToken()); p[i].y = Integer.parseInt(st.nextToken()) + Integer.parseInt(st.nextToken()); } Arrays.sort(p, new Comparator(){
@Override
public int compare(Point p1, Point p2) {
return p2.y – p1.y;
}
});
for(int i = 0; i < N; i++){ tim += p[i].x; ar[i] = tim + p[i].y; } int m = 0; for(int x : ar){ m = (x > m) ? x : m;
}
System.out.println(m);

}

}

My list of recommended Web Comics

Sunday, April 23rd, 2017

Who doesnt love comics. And who doesnt love the web ? See where Im going with this ?

And you get Web Comics. An amazing story full of with cliff hangers as you wait a whole week to read three panels and maybe months together to get a complete fulfilling scene play out. But, they do have their appeal. The variety of authors and their individualism in expression come together to ensure that however dark or cheerful you are, there is definitely a webcomic out there so tailored to you that youll feel as if you wrote it yourself.

Undead Ed :
UnDeadEdA completed story by Boredman a french cartoonist with a dark but equally quirky art style. Is a zombie also a ghoul ? Do vampires drink red wine or white wine ? The protagonist gets to find out.
Read for the funny story, well laid out art and also the very funny jokes.

unOrdinary :

A recently started toon which takes place in a normal school setting, complete with normal students who have superpowers. Very normal isn’t it ? The art is good but has nothing which stands out. None the less, the story is a must read. Youll feel compelled to read this week after week. John the new transfer student says he has no powers, and so is bullied by everyone else. But obviously he, being the protagonist has somewhat of a troubled past.

Live with Yourself! :

Have you wondered how/what youll be when you are 60. And also, we wonder about our baby days. We keep wondering about tomorrow as well. One person split into his baby-self, tomorrow-self and 60 year old-self become housemates as they wonder how they each return to their own timelines. Thats the premise of this comic obviously authored by Shen. Shenpai has a very striking art style which has become his trademark.

 

Tower of God :

I couldn’t find an image to describe TOG better so bear with this promo poster I had to dig up. A beautiful story with long chapters every week, lots of characters, cool powers, complex plot and even more complex plot tools. The premise may never fit in with reality, but the sheer weight of the story begins to grow on you. You’ll get confused with the names and the characters a lot and that might be a big issue had the story and its execution not been so top notch.

Questionable Content :

A long running comic by Jeph Jacques. He basically writes this for a living, you can see his art style improve vastly over the years, the character development is amazing, new faces come and go but they are always properly built up that you feel sad they are going. Must read, but just be prepared to be in for a lot of it.