Submission #996447

#TimeUsernameProblemLanguageResultExecution timeMemory
996447fryingducBoxes with souvenirs (IOI15_boxes)C++17
Compilation error
0 ms0 KiB
const int maxn = 1e7 + 7;
long long fcw[maxn], fccw[maxn];
long long delivery(int n, int k, int l, int pos[]) {
    for(int i = 1; i <= n; ++i) {
        fcw[i] = fcw[max(0, i - k)] + pos[i] + min(pos[i], l - pos[i]); 
    }
    for(int i = n; i; --i) {
        fccw[i] = fccw[min(n + 1, i + k)] + (l - pos[i]) + min(pos[i], l - pos[i]);
    }
    
    long long ans = 1e18;
    for(int i = 1; i <= n; ++i) {
        ans = min(ans, fccw[i] + fcw[i] - min(pos[i], l - pos[i]));
    }
    cout << ans;
}

Compilation message (stderr)

boxes.cpp: In function 'long long int delivery(int, int, int, int*)':
boxes.cpp:5:22: error: 'max' was not declared in this scope; did you mean 'maxn'?
    5 |         fcw[i] = fcw[max(0, i - k)] + pos[i] + min(pos[i], l - pos[i]);
      |                      ^~~
      |                      maxn
boxes.cpp:5:48: error: 'min' was not declared in this scope
    5 |         fcw[i] = fcw[max(0, i - k)] + pos[i] + min(pos[i], l - pos[i]);
      |                                                ^~~
boxes.cpp:8:24: error: 'min' was not declared in this scope
    8 |         fccw[i] = fccw[min(n + 1, i + k)] + (l - pos[i]) + min(pos[i], l - pos[i]);
      |                        ^~~
boxes.cpp:13:43: error: 'min' was not declared in this scope
   13 |         ans = min(ans, fccw[i] + fcw[i] - min(pos[i], l - pos[i]));
      |                                           ^~~
boxes.cpp:13:15: error: 'min' was not declared in this scope
   13 |         ans = min(ans, fccw[i] + fcw[i] - min(pos[i], l - pos[i]));
      |               ^~~
boxes.cpp:15:5: error: 'cout' was not declared in this scope
   15 |     cout << ans;
      |     ^~~~
boxes.cpp:16:1: warning: no return statement in function returning non-void [-Wreturn-type]
   16 | }
      | ^