제출 #30551

#제출 시각아이디문제언어결과실행 시간메모리
30551kavun선물상자 (IOI15_boxes)C++14
100 / 100
584 ms170972 KiB
#include "boxes.h" #include <bits/stdc++.h> #define pb push_back using namespace std; typedef long long ll; long long n,l,k,ans = 1e18; vector <ll> lft,rgt; long long delivery(int N, int K, int L, int p[]) { n = N; k = K; for(int i = 0; i < n; i++) { if(p[i] <= L/2) lft.push_back(p[i]*2); else rgt.push_back(2*(L-p[i])); } reverse(rgt.begin(),rgt.end()); for(int i = k; i < lft.size(); i++) lft[i] = lft[i-k] + lft[i]; for(int i = k; i < rgt.size(); i++) rgt[i] = rgt[i-k] + rgt[i]; for(int i = 0; i <= k; i++) { int x = i; int y = k-i; ans = min(ans, (x < lft.size() ? lft[lft.size() - 1 - x] : 0) + (y < rgt.size() ? rgt[rgt.size() - 1 - y] : 0) + L); } return min(ans, (lft.size() ? lft.back() : 0) + (rgt.size() ? rgt.back() : 0)); }

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

boxes.cpp: In function 'long long int delivery(int, int, int, int*)':
boxes.cpp:22:15: warning: conversion to 'int' from 'long long int' may alter its value [-Wconversion]
   for(int i = k; i < lft.size(); i++)
               ^
boxes.cpp:22:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int i = k; i < lft.size(); i++)
                  ~~^~~~~~~~~~~~
boxes.cpp:24:15: warning: conversion to 'int' from 'long long int' may alter its value [-Wconversion]
   for(int i = k; i < rgt.size(); i++)
               ^
boxes.cpp:24:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int i = k; i < rgt.size(); i++)
                  ~~^~~~~~~~~~~~
boxes.cpp:29:16: warning: conversion to 'int' from 'long long int' may alter its value [-Wconversion]
       int y = k-i;
               ~^~
boxes.cpp:30:25: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
       ans = min(ans, (x < lft.size() ? lft[lft.size() - 1 - x] : 0) + (y < rgt.size() ?  rgt[rgt.size() - 1 - y] : 0) + L);
                       ~~^~~~~~~~~~~~
boxes.cpp:30:74: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
       ans = min(ans, (x < lft.size() ? lft[lft.size() - 1 - x] : 0) + (y < rgt.size() ?  rgt[rgt.size() - 1 - y] : 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...