Submission #176091

#TimeUsernameProblemLanguageResultExecution timeMemory
176091mat_vBoxes with souvenirs (IOI15_boxes)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> #include "boxes.h" #define maxn 10000005 using namespace std; typedef long long ll; int n,k; int niz[maxn]; int d; set<int>s; ll dist(int l, int r){ if(l > r)swap(l, r); ll res = min(r - l, l + d - r); return res; } long long delivery(int N, int K, int L, int p[]) { n = N, k = K, d = L; ff(i,1,n)niz[i] = p[i - 1]; ff(i,1,n){ s.insert(niz[i]); } int poz = 0; int cap = k; ll res = 0; while(s.size() > 0){ if(cap == 0){ res += dist(poz, 0); poz = 0; cap = k; continue; } int levi = *s.begin(); int desni = *s.rbegin(); int dist1 = dist(levi, poz); int dist2 = dist(desni, poz); int najbliza; if(dist1 < dist2)najbliza = levi; else najbliza = desni; if(abs(najbliza - poz) + dist(poz, 0) <= dist(najbliza,0) + dist(poz,0)){ res += abs(najbliza - poz); poz = najbliza; cap--; s.erase(najbliza); } else{ res += dist(poz, 0); poz = 0; } } return res; }

Compilation message (stderr)

boxes.cpp: In function 'long long int delivery(int, int, int, int*)':
boxes.cpp:18:8: error: 'i' was not declared in this scope
     ff(i,1,n)niz[i] = p[i - 1];
        ^
boxes.cpp:18:5: error: 'ff' was not declared in this scope
     ff(i,1,n)niz[i] = p[i - 1];
     ^~
boxes.cpp:18:5: note: suggested alternative: 'ffs'
     ff(i,1,n)niz[i] = p[i - 1];
     ^~
     ffs
boxes.cpp:34:25: warning: conversion to 'int' from 'll {aka long long int}' may alter its value [-Wconversion]
         int dist1 = dist(levi, poz);
                     ~~~~^~~~~~~~~~~
boxes.cpp:35:25: warning: conversion to 'int' from 'll {aka long long int}' may alter its value [-Wconversion]
         int dist2 = dist(desni, poz);
                     ~~~~^~~~~~~~~~~~
boxes.cpp:16:47: warning: unused parameter 'p' [-Wunused-parameter]
 long long delivery(int N, int K, int L, int p[]) {
                                               ^