제출 #754463

#제출 시각아이디문제언어결과실행 시간메모리
754463sofija6선물상자 (IOI15_boxes)C++14
50 / 100
50 ms18884 KiB
#include "boxes.h" #include <bits/stdc++.h> using namespace std; long long delivery(int N, int K, int L, int p[]) { vector<int> left,right; for (int i=0;i<N && p[i]<=L/2;i++) left.push_back(p[i]); for (int i=N-1;i>=0 && p[i]>L/2;i--) right.push_back(p[i]); long long ans=LLONG_MAX,cur=0; for (int i=left.size()-1;i>=0;i-=K) cur+=2*left[i]; for (int i=right.size()-1;i>=0;i-=K) cur+=2*(L-right[i]); ans=min(ans,cur); cur=L; for (int i=left.size()-left.size()%K-1;i>=0;i-=K) cur+=2*left[i]; for (int i=right.size()-(K-left.size()%K)-1;i>=0;i-=K) cur+=2*(L-right[i]); ans=min(ans,cur); cur=L; for (int i=left.size()-(K-right.size()%K)-1;i>=0;i-=K) cur+=2*left[i]; for (int i=right.size()-right.size()%K-1;i>=0;i-=K) cur+=2*(L-right[i]); return min(ans,cur); }

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

boxes.cpp: In function 'long long int delivery(int, int, int, int*)':
boxes.cpp:12:27: warning: conversion from 'std::vector<int>::size_type' {aka 'long unsigned int'} to 'int' may change value [-Wconversion]
   12 |     for (int i=left.size()-1;i>=0;i-=K)
      |                ~~~~~~~~~~~^~
boxes.cpp:14:28: warning: conversion from 'std::vector<int>::size_type' {aka 'long unsigned int'} to 'int' may change value [-Wconversion]
   14 |     for (int i=right.size()-1;i>=0;i-=K)
      |                ~~~~~~~~~~~~^~
boxes.cpp:18:41: warning: conversion from 'std::vector<int>::size_type' {aka 'long unsigned int'} to 'int' may change value [-Wconversion]
   18 |     for (int i=left.size()-left.size()%K-1;i>=0;i-=K)
      |                ~~~~~~~~~~~~~~~~~~~~~~~~~^~
boxes.cpp:20:46: warning: conversion from 'std::vector<int>::size_type' {aka 'long unsigned int'} to 'int' may change value [-Wconversion]
   20 |     for (int i=right.size()-(K-left.size()%K)-1;i>=0;i-=K)
      |                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~
boxes.cpp:24:46: warning: conversion from 'std::vector<int>::size_type' {aka 'long unsigned int'} to 'int' may change value [-Wconversion]
   24 |     for (int i=left.size()-(K-right.size()%K)-1;i>=0;i-=K)
      |                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~
boxes.cpp:26:43: warning: conversion from 'std::vector<int>::size_type' {aka 'long unsigned int'} to 'int' may change value [-Wconversion]
   26 |     for (int i=right.size()-right.size()%K-1;i>=0;i-=K)
      |                ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~
#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...