Submission #388938

#TimeUsernameProblemLanguageResultExecution timeMemory
388938cpp219Boxes with souvenirs (IOI15_boxes)C++14
Compilation error
0 ms0 KiB
vector<int> v[2]; ll f[2][N],lens,k; ll Dist(ll x,ll y){ return min(abs(x - y),lens - abs(x - y)); } void cal(ll cond){ ll sz = v[cond].size(); for (ll i = 0;i < min(sz,k);i++){ ll now = 0; for (ll j = i;j < sz;j += k){ now += Dist(0,v[cond][j]); f[cond][j] = 2*now; } } } ll delivery(int n,int K,int L,int pos[]){ lens = L; k = K; for (ll i = 0;i < n;i++){ if (pos[i] <= L/2) v[0].push_back(pos[i]); else v[1].push_back(pos[i]); } reverse(v[1].begin(),v[1].end()); ll sz0 = v[0].size() - 1,sz1 = v[1].size() - 1; cal(1); cal(1); ll ans = f[0][max(0ll,sz0)] + f[1][max(0ll,sz1)]; //cout<<f[0][2]; exit(0); //cout<<f[1][2]; exit(0); for (ll i = 1;i < k;i++){ ll p = 0,q = 0; //if (sz1 - i + 1 < 0||sz0 - k + i + 1 < 0) break; if (sz1 - i >= 0) q = f[1][sz1 - i]; if (sz0 - k + i >= 0) p = f[0][sz0 - k + i]; ll now = p + L + q; //cout<<sz0 - k<<"x"; exit(0); ans = min(ans,now); } return ans; }

Compilation message (stderr)

boxes.cpp:1:1: error: 'vector' does not name a type
    1 | vector<int> v[2];
      | ^~~~~~
boxes.cpp:2:1: error: 'll' does not name a type
    2 | ll f[2][N],lens,k;
      | ^~
boxes.cpp:4:1: error: 'll' does not name a type
    4 | ll Dist(ll x,ll y){
      | ^~
boxes.cpp:8:10: error: variable or field 'cal' declared void
    8 | void cal(ll cond){
      |          ^~
boxes.cpp:8:10: error: 'll' was not declared in this scope
boxes.cpp:18:1: error: 'll' does not name a type
   18 | ll delivery(int n,int K,int L,int pos[]){
      | ^~