Wednesday, June 25, 2014

TopCoder High School SRM 16 level one - 250 pt - Missed Call solution

TopCoder High School SRM 16 level one - 250 pt - Missed Call statement: http://community.topcoder.com/stat?c=problem_statement&pm=6783&rd=10068

TopCoder High School SRM 16 level one - 250 pt - Missed Call editorial: http://community.topcoder.com/tc?module=Static&d1=hs&d2=match_editorials&d3=hs_srm16

TopCoder High School SRM 16 level one - 250 pt - Missed Call solution: 

#include <iostream>

class MissedCall {
    public: int waitingTime(int n, int s, int d) {
        int a[5000]={0}, idx;
        for(int i=0, j=1; j<=n; i+=s+5, j++) for(int k=i; k<i+s; k++) a[k]=1;
        for(int i=0; i<5000; i+=d) if(a[i]==0) {idx=i; break;}
        return idx;
    }
};

No comments:

Post a Comment