제출 #1007931

#제출 시각아이디문제언어결과실행 시간메모리
1007931andro선물상자 (IOI15_boxes)C++14
10 / 100
1 ms348 KiB
#include <bits/stdc++.h> #include "boxes.h" using namespace std; long long delivery(int N, int K, int L, int p[]) { long long ans = 0; vector<int> b1, b2; for(int i = 0; i < N; i++) { if(p[i] <= L - p[i]) { b1.push_back(p[i]); } else { b2.push_back(p[i]); } } int r = K; for(int i = 0; i < b1.size(); i++) { r -= 1; if(! r) { ans += b1[i] * 2; r = K; } else { continue; } } int idx = b2.size() - 1; if(r != K) { while(r > 0) { idx -= 1; r -= 1; } ans += (L - b2[idx]) * 2; } r = K; for(int i = 0; i <= idx; i++) { r -= 1; if(! r) { ans += (L - b2[i]) * 2; r = K; } else { continue; } } if(r != K) { if(r > 0) { ans += (L - b2[idx]) * 2; } } return ans; } /* int main() { int X[3] = {1, 2, 5}; cout << delivery(3, 2, 8, X); }*/

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

boxes.cpp: In function 'long long int delivery(int, int, int, int*)':
boxes.cpp:19:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   19 |     for(int i = 0; i < b1.size(); i++) {
      |                    ~~^~~~~~~~~~~
boxes.cpp:29:25: warning: conversion from 'std::vector<int>::size_type' {aka 'long unsigned int'} to 'int' may change value [-Wconversion]
   29 |     int idx = b2.size() - 1;
      |               ~~~~~~~~~~^~~
#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...