Submission #588364

#TimeUsernameProblemLanguageResultExecution timeMemory
588364TemmieBoxes with souvenirs (IOI15_boxes)C++17
20 / 100
1 ms296 KiB
#include "boxes.h" #include <bits/stdc++.h> struct State { long long time = 0; }; int dist(int place, int n) { return std::min(place, n - place); } long long delivery(int n, int k, int l, int pos[]) { std::sort(pos, pos + n); std::vector <State> right(n + 1); long long time = 0; long long place = 0; for (int i = 1; i <= n; i++) { if ((i - 1) % k == 0) { time += dist(place, l); place = 0; } time += std::min(abs(pos[i - 1] - place), l - abs(pos[i - 1] - place)); place = pos[i - 1]; right[i] = { time + dist(place, l) }; } std::vector <State> left(n + 1); time = 0; place = 0; for (int i = 1; i <= n; i++) { int j = n - i; if ((i - 1) % k == 0) { time += dist(place, l); place = 0; } time += std::min(abs(pos[j] - place), l - abs(pos[j] - place)); place = pos[j]; left[i] = { time + dist(place, l) }; } long long ans = 1LL << 60; for (int i = 0; i <= n; i++) { int oth = n - i; ans = std::min(ans, right[i].time + left[oth].time); } return ans; } //int main() { //int a[3] = { 1, 2, 5 }; //std::cout << delivery(3, 2, 8, a) << std::endl; //}

Compilation message (stderr)

boxes.cpp: In function 'long long int delivery(int, int, int, int*)':
boxes.cpp:19:17: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   19 |    time += dist(place, l);
      |                 ^~~~~
boxes.cpp:22:35: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   22 |   time += std::min(abs(pos[i - 1] - place), l - abs(pos[i - 1] - place));
      |                        ~~~~~~~~~~~^~~~~~~
boxes.cpp:22:64: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   22 |   time += std::min(abs(pos[i - 1] - place), l - abs(pos[i - 1] - place));
      |                                                     ~~~~~~~~~~~^~~~~~~
boxes.cpp:24:28: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   24 |   right[i] = { time + dist(place, l) };
      |                            ^~~~~
boxes.cpp:32:17: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   32 |    time += dist(place, l);
      |                 ^~~~~
boxes.cpp:35:31: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   35 |   time += std::min(abs(pos[j] - place), l - abs(pos[j] - place));
      |                        ~~~~~~~^~~~~~~
boxes.cpp:35:56: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   35 |   time += std::min(abs(pos[j] - place), l - abs(pos[j] - place));
      |                                                 ~~~~~~~^~~~~~~
boxes.cpp:37:27: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   37 |   left[i] = { time + dist(place, l) };
      |                           ^~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...