제출 #839030

#제출 시각아이디문제언어결과실행 시간메모리
839030PagodePaivaBoxes with souvenirs (IOI15_boxes)C++17
0 / 100
2064 ms212 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--; } else{ res += dist(at, p[l], L); at = p[l]; if(aux) caixas = k; caixas--; } } 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:36:25: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   36 |             res += dist(at, p[l], L);
      |                         ^~
boxes.cpp:43:17: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   43 |     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...