Submission #1081960

#TimeUsernameProblemLanguageResultExecution timeMemory
1081960raphael_heuchlBoxes with souvenirs (IOI15_boxes)C++14
10 / 100
2 ms348 KiB
#include "boxes.h" #include <vector> #include <algorithm> #include <map> #include <iostream> #define INF 1'000'000'000'000'000'000 std::vector<long long> people; long long n, l, k; long long dist(long long curr) { return std::min(l - people[curr], people[curr]); } long long dp[1005]; long long delivery(int N, int K, int L, int p[]) { n = N, k = K, l = L; people.push_back(0); for (int i = 0; i < N; ++i) people.push_back(p[i]); std::sort(people.begin(), people.end()); for (int j = K-1; j >= 0; --j) dp[j] = dist(N); for (int i = N-1; i >= 0; --i) { int var = dp[K-1]; for (int j = K-1; j >= 0; --j) { long long optionA = j ? std::abs(people[i] - people[i + 1]) + dp[j-1] : INF; long long optionB = dist(i) + dist(i+1) + var; dp[j] = std::min(optionA, optionB); } } return dp[K - 1]; }

Compilation message (stderr)

boxes.cpp: In function 'long long int delivery(int, int, int, int*)':
boxes.cpp:29:25: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   29 |         int var = dp[K-1];
      |                   ~~~~~~^
#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...