제출 #419154

#제출 시각아이디문제언어결과실행 시간메모리
419154LouayFarah선물상자 (IOI15_boxes)C++14
컴파일 에러
0 ms0 KiB
#include "bits/stdc++.h" #include "boxes.h" using namespace std; int delivery(int n, int k, int l, int positions[]) { if(k==1) { int res = 0; for(int i = 0; i<n; i++) { if(positions[i]>l/2) { res+=2*(l-positions[i]); } else { res+=2*(positions[i]); } } return res; } else if(k==n) { long long a = 0, b = 0, c = 0, d = 1e18; a = l; b = 2*positions[n-1]; c = 2*(l - positions[0]); long long left = -1, right = 0; for(int i = 0; i<n; i++) { if(positions[i]>=l/2) { if(i>0) { left = positions[i]; right = positions[i-1]; break; } else break; } } if(left!=-1) d = 2*(l - left) + 2*right; return min(min(a,b), min(c, d)); } else { } }

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

boxes.cpp:5:5: error: ambiguating new declaration of 'int delivery(int, int, int, int*)'
    5 | int delivery(int n, int k, int l, int positions[])
      |     ^~~~~~~~
In file included from boxes.cpp:2:
boxes.h:4:11: note: old declaration 'long long int delivery(int, int, int, int*)'
    4 | long long delivery(int N, int K, int L, int p[]);
      |           ^~~~~~~~
boxes.cpp: In function 'int delivery(int, int, int, int*)':
boxes.cpp:48:19: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   48 |         return min(min(a,b), min(c, d));
      |                ~~~^~~~~~~~~~~~~~~~~~~~~
boxes.cpp:55:1: warning: control reaches end of non-void function [-Wreturn-type]
   55 | }
      | ^