Submission #428518

# Submission time Handle Problem Language Result Execution time Memory
428518 2021-06-15T12:31:39 Z Mazaalai Boxes with souvenirs (IOI15_boxes) C++14
0 / 100
1 ms 256 KB
#include "boxes.h"
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll n, k, l, ans, tmp;
vector <int> p;

long long delivery(int N, int K, int L, int P[]) {
    n = N, k = K, l = L;
    for (int i = 0; i < n; i++) p.push_back(P[i]);
    int mid = l / 2, mid1 = l - mid;
    sort(p.begin(), p.end());
    int a = 0, b = n-1, a1, b1;
    while(a < n && p[a] == 0) a++;
    while(a + k - 1 <= b) {
        a1 = a + k - 1;
        b1 = b - k + 1;
        if (a1 <= mid) {
            a = a1+1;
            ans += p[a1]*2;
            continue;
        }
        if (b1 >= mid1) {
            b = b1-1;
            ans += (l - p[b1])*2;
            continue;
        }
    }
    if (a <= b) {
        if (p[a] <= mid && p[b] >= mid1) ans += l;
        else ans += min(p[b], L-p[a])*2;
    }
    return ans;
}

Compilation message

boxes.cpp: In function 'long long int delivery(int, int, int, int*)':
boxes.cpp:11:17: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
   11 |     int mid = l / 2, mid1 = l - mid;
      |               ~~^~~
boxes.cpp:11:31: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
   11 |     int mid = l / 2, mid1 = l - mid;
      |                             ~~^~~~~
boxes.cpp:13:21: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
   13 |     int a = 0, b = n-1, a1, b1;
      |                    ~^~
boxes.cpp:16:20: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
   16 |         a1 = a + k - 1;
      |              ~~~~~~^~~
boxes.cpp:17:20: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
   17 |         b1 = b - k + 1;
      |              ~~~~~~^~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Incorrect 1 ms 204 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Incorrect 1 ms 204 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Incorrect 1 ms 204 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Incorrect 1 ms 204 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Incorrect 1 ms 204 KB Output isn't correct
3 Halted 0 ms 0 KB -