Tuesday, December 23, 2014

Topcoder SRM 640 div2 250point

this question is very easy!!

start and ribons

if left and right is different counting ++

my code is below~


problem
http://community.topcoder.com/stat?c=problem_statement&pm=13556



 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
public class ChristmasTreeDecorationDiv2 {

 public int solve(int[] col, int[] x, int[] y){
  int len = x.length;
  int cnt =0;
  for(int i=0; i<len; i++){
   if(col[x[i]-1] != col[y[i]-1]){
    cnt++;
   }
  }
  return cnt;
 }
}

No comments:

Post a Comment