// Topcoder SRM 573 DIV 2 1 SkiResortsEasy
import java.util.*;
import java.math.*;
import javax.crypto.spec.PSource;
public class SkiResortsEasy {
public static void main(String[] args) {
System.out.println(
//
new SkiResortsEasy().minCost(
null
));
}
public int minCost(int[] altitude) {
int minCost = 0;
for (int i = 1; i < altitude.length; i++) {
if (altitude[i] > altitude[i - 1]) {
int diff = altitude[i] - altitude[i - 1];
altitude[i] -= diff;
minCost += diff;
}
}
return minCost;
}
}
No comments:
Post a Comment