Submission #574714

#TimeUsernameProblemLanguageResultExecution timeMemory
574714stevancv선물상자 (IOI15_boxes)C++14
10 / 100
1 ms340 KiB
#include <bits/stdc++.h> #include "boxes.h" #define ll long long #define ld long double #define sp ' ' #define en '\n' #define smin(a, b) a = min(a, b) #define smax(a, b) a = max(a, b) using namespace std; const int N = 2e5 + 2; ll delivery(int N, int K, int D, int pos[]) { ll n = N; ll k = K; ll d = D; vector<ll> a(n + 2); for (int i = 1; i <= n; i++) a[i] = pos[i - 1]; a[n + 1] = d; int l = 0, r = n + 1; ll ans = 1e18; while (l < r) { ll kolko = r - l - 1; kolko = (kolko + k - 1) / k; smin(ans, 2 * (a[l] + d - a[r]) + kolko * d); ll x = 2 * (a[l + 1] - a[l]); ll y = 2 * (a[r] - a[r - 1]); if (x < y) l++; else r--; } return ans; }

Compilation message (stderr)

boxes.cpp: In function 'long long int delivery(int, int, int, int*)':
boxes.cpp:11:17: warning: declaration of 'N' shadows a global declaration [-Wshadow]
   11 | ll delivery(int N, int K, int D, int pos[]) {
      |             ~~~~^
boxes.cpp:10:11: note: shadowed declaration is here
   10 | const int N = 2e5 + 2;
      |           ^
boxes.cpp:18:22: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   18 |     int l = 0, r = n + 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...