Submission #1154390

#TimeUsernameProblemLanguageResultExecution timeMemory
1154390ZheingBoxes with souvenirs (IOI15_boxes)C++20
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll inf = 1e18;

ll delivery(int n, int k, int L, int X[]){
    vector<long long int> positions;
    for (int i = 0; i < N; i++){
        positions[i] = X[i];
    }
    vector<long long> clockwise, anticlockwise;
    for (int i = 0; i < N; i++){
        long long pos = positions[i];
        if (2 * pos <= L)
            clockwise.push_back(pos);
        else
            anticlockwise.push_back(L - pos);
    }
    
    sort(clockwise.begin(), clockwise.end(), greater<long long>());
    sort(anticlockwise.begin(), anticlockwise.end(), greater<long long>());
    
    long long total_time = 0;
    for (int i = 0; i < clockwise.size(); i += K){
        total_time += 2 * clockwise[i];
    }
    
    for (int i = 0; i < anticlockwise.size(); i += K){
        total_time += 2 * anticlockwise[i];
    }
    return total_time;    
}

Compilation message (stderr)

boxes.cpp: In function 'll delivery(int, int, int, int*)':
boxes.cpp:8:25: error: 'N' was not declared in this scope
    8 |     for (int i = 0; i < N; i++){
      |                         ^
boxes.cpp:12:25: error: 'N' was not declared in this scope
   12 |     for (int i = 0; i < N; i++){
      |                         ^
boxes.cpp:24:48: error: 'K' was not declared in this scope
   24 |     for (int i = 0; i < clockwise.size(); i += K){
      |                                                ^
boxes.cpp:28:52: error: 'K' was not declared in this scope
   28 |     for (int i = 0; i < anticlockwise.size(); i += K){
      |                                                    ^