Submission #1216709

#TimeUsernameProblemLanguageResultExecution timeMemory
1216709lizi14Boxes with souvenirs (IOI15_boxes)C++20
Compilation error
0 ms0 KiB
#include "boxes.h"
using namespace std;
long long delivery(int N, int K, int L, int p[]) {
    int x[L];
    fill(x,x+L,0);
    for(int i=0; i<n; i++){
        cin>>p[i];
        x[p[i]]=1;
    }
    int ans=0;
    for(int i=1; i<L; i++){
        if(x[i]==1){
            ans+=min(i,l-i);
        }
    }
    return (ans*2);
}

Compilation message (stderr)

boxes.cpp: In function 'long long int delivery(int, int, int, int*)':
boxes.cpp:5:5: error: 'fill' was not declared in this scope
    5 |     fill(x,x+L,0);
      |     ^~~~
boxes.cpp:6:20: error: 'n' was not declared in this scope
    6 |     for(int i=0; i<n; i++){
      |                    ^
boxes.cpp:7:9: error: 'cin' was not declared in this scope
    7 |         cin>>p[i];
      |         ^~~
boxes.cpp:2:1: note: 'std::cin' is defined in header '<iostream>'; did you forget to '#include <iostream>'?
    1 | #include "boxes.h"
  +++ |+#include <iostream>
    2 | using namespace std;
boxes.cpp:13:24: error: 'l' was not declared in this scope
   13 |             ans+=min(i,l-i);
      |                        ^
boxes.cpp:13:18: error: 'min' was not declared in this scope
   13 |             ans+=min(i,l-i);
      |                  ^~~