stostap's blog

By stostap, history, 8 years ago, In English

http://www.spoj.com/problems/TROOPS/

Hi, could you give any hints why dp approach here giving WA?

REP(i, n) {
 int x,y,z;
 scanf("%d%d%d", &x, &y, &z);
 FOR(j, max(1, y - x + 1), y + 1) {
  a[j] = max(a[j], z);
 }
}
int sum = 0;
REP(i, T) {
 sum += a[i];
}

Thanks!

  • Vote: I like it
  • 0
  • Vote: I do not like it