제출 #513984

#제출 시각아이디문제언어결과실행 시간메모리
513984Leo121선물상자 (IOI15_boxes)C++14
컴파일 에러
0 ms0 KiB
#include "boxes.h" #include <bits/stdc++.h> #define fi first #define se second #define pb push_back #define mp male_pair #define forn(i, a, b) for(int i = int(a); i <= int(b); ++ i) #define fora(i, a, b) for(int i = int(a); i >= int(b); -- i) using namespace std; typedef long long ll; typedef pair<ll, int> pli; typedef vector<ll> vl; long long delivery(int N, int K, int L, int p[]) { vl menores; vl mayores; menores.pb(0LL); forn(i, 0, N - 1){ if(!p[i]){ continue; } if(p[i] <= L / 2){ menores.pb((ll) p[i] * 2LL); } else{ mayores.pb(((ll) L - (ll) p[i]) * 2LL); } } mayores.pb(0LL); int lon1 = menores.size(), lon2 = mayores.size(); forn(i, K + 1, lon1 - 1){ menores[i] += menores[i - K]; } reverse(mayores.begin(), mayores.end()); forn(i, K + 1, lon2){ mayores[i] += mayores[i - k]; } if(lon1 == 1 && lon2 == 1){ return 0LL; } if(lon1 == 1){ return mayores[lon2 - 1]; } if(lon2 == 1){ return menores[lon1 - 1]; } ll res = mayores[lon2 - 1] + menores[lon1 - 1]; forn(i, 1, K - 1){ res = min(res, menores[max(lon1 - i - 1, 0)] + mayores[max(lon2 - (K - i) - 1, 0)] + L); } return res; }

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

boxes.cpp: In function 'long long int delivery(int, int, int, int*)':
boxes.cpp:32:28: warning: conversion from 'std::vector<long long int>::size_type' {aka 'long unsigned int'} to 'int' may change value [-Wconversion]
   32 |     int lon1 = menores.size(), lon2 = mayores.size();
      |                ~~~~~~~~~~~~^~
boxes.cpp:32:51: warning: conversion from 'std::vector<long long int>::size_type' {aka 'long unsigned int'} to 'int' may change value [-Wconversion]
   32 |     int lon1 = menores.size(), lon2 = mayores.size();
      |                                       ~~~~~~~~~~~~^~
boxes.cpp:38:35: error: 'k' was not declared in this scope
   38 |         mayores[i] += mayores[i - k];
      |                                   ^