제출 #839031

#제출 시각아이디문제언어결과실행 시간메모리
839031PagodePaivaBoxes with souvenirs (IOI15_boxes)C++14
0 / 100
1 ms304 KiB
#include "boxes.h"
#include <bits/stdc++.h>

using namespace std;

bool aux = false;

int dist(int a, int b, int L){
    if(L-abs(a-b) >=  abs(a-b)) aux = true;
    else aux = false;
    return min(abs(a-b), abs(L - abs(a-b)));
}

long long delivery(int n, int k, int L, int p[]) {
    int l = 0, r = n-1;

    int caixas = k;
    long long res = 0;
    long long at = 0;

    while(l < r){
        if(caixas == 0){
            res += dist(0, at, L);
            caixas = k;
            at = 0;       
        }

        if(dist(at, p[l], L) > dist(at, p[r], L)){
            res += dist(at, p[r], L);
            at = p[r];
            if(aux) caixas = k;
            caixas--;
            r--;
        }

        else{
            res += dist(at, p[l], L);
            at = p[l];
            if(aux) caixas = k;
            caixas--;
            l++;
        }
    }

    res += dist(at, 0, L);
    
    return res;
}

컴파일 시 표준 에러 (stderr) 메시지

boxes.cpp: In function 'long long int delivery(int, int, int, int*)':
boxes.cpp:23:28: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   23 |             res += dist(0, at, L);
      |                            ^~
boxes.cpp:28:17: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   28 |         if(dist(at, p[l], L) > dist(at, p[r], L)){
      |                 ^~
boxes.cpp:28:37: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   28 |         if(dist(at, p[l], L) > dist(at, p[r], L)){
      |                                     ^~
boxes.cpp:29:25: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   29 |             res += dist(at, p[r], L);
      |                         ^~
boxes.cpp:37:25: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   37 |             res += dist(at, p[l], L);
      |                         ^~
boxes.cpp:45:17: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   45 |     res += dist(at, 0, 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...