Submission #1040027

#TimeUsernameProblemLanguageResultExecution timeMemory
1040027KiprasBoxes with souvenirs (IOI15_boxes)C++17
Compilation error
0 ms0 KiB
#include "boxes.h" #include <bits/stdc++.h> typedef long long ll; using namespace std; ll delivery(ll n, ll k, ll l, ll[] pos){ ll mid = (l+1)/2; vector<ll> dp1, dp2; dp1.push_back(0); dp2.push_back(0); for(int i = 0; i < n && pos[i]<=mid; i++){ if(i==0){ dp1.push_back(pos[i]*2); continue; } if(i%k!=0)dp1.push_back(pos[i]*2-pos[i-1]); else dp1.push_back(dp1.back()+pos[i]); } for(int x = n-1; x >= 0 && pos[x]>=mid; x--){ if(x==n-1){ dp2.push_back(pos[x]*2); continue; } ll ind = x-n+1; if(ind%k!=0)dp2.push_back(pos[x]*2-pos[x+1]); else dp2.push_back(dp1.back()+pos[x]); } ll rez = 1e18; for(int i = 0; i < dp1.size(); i++){ if(dp2.size()>n-i)rez=min(rez, dp1[i] + dp2[n-i]); if(dp2.size()>n-i-k&&n-i-k>=0)rez=min(rez, dp1[i] + dp2[n-i-l] + l); } return rez; }

Compilation message (stderr)

boxes.cpp:8:36: error: expected ',' or '...' before 'pos'
    8 | ll delivery(ll n, ll k, ll l, ll[] pos){
      |                                    ^~~
boxes.cpp: In function 'll delivery(ll, ll, ll, ll*)':
boxes.cpp:16:29: error: 'pos' was not declared in this scope; did you mean 'pow'?
   16 |     for(int i = 0; i < n && pos[i]<=mid; i++){
      |                             ^~~
      |                             pow
boxes.cpp:26:18: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
   26 |     for(int x = n-1; x >= 0 && pos[x]>=mid; x--){
      |                 ~^~
boxes.cpp:26:32: error: 'pos' was not declared in this scope; did you mean 'pow'?
   26 |     for(int x = n-1; x >= 0 && pos[x]>=mid; x--){
      |                                ^~~
      |                                pow
boxes.cpp:38:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   38 |     for(int i = 0; i < dp1.size(); i++){
      |                    ~~^~~~~~~~~~~~
boxes.cpp:39:22: warning: comparison of integer expressions of different signedness: 'std::vector<long long int>::size_type' {aka 'long unsigned int'} and 'll' {aka 'long long int'} [-Wsign-compare]
   39 |         if(dp2.size()>n-i)rez=min(rez, dp1[i] + dp2[n-i]);
      |            ~~~~~~~~~~^~~~
boxes.cpp:40:22: warning: comparison of integer expressions of different signedness: 'std::vector<long long int>::size_type' {aka 'long unsigned int'} and 'll' {aka 'long long int'} [-Wsign-compare]
   40 |         if(dp2.size()>n-i-k&&n-i-k>=0)rez=min(rez, dp1[i] + dp2[n-i-l] + l);
      |            ~~~~~~~~~~^~~~~~