제출 #276009

#제출 시각아이디문제언어결과실행 시간메모리
276009stoyan_malinin선물상자 (IOI15_boxes)C++14
10 / 100
1 ms384 KiB
#include "boxes.h" //#include "grader.cpp" #include <vector> #include <iostream> #include <algorithm> using namespace std; int n, k, l; long long evalVector(vector <int> v, int sz) { long long answer = 0; for(int i = sz;i>=0;i-=k) answer += 2*min(v[i], l-v[i]);//, cout << v[i] << '\n' return answer; } long long solve(vector <int> v1, vector <int> v2) { long long answer = 0; answer = evalVector(v1, v1.size()-1) + evalVector(v2, v2.size()-1); return answer; } vector <int> invertVector(vector <int> v) { vector <int> out; for(int x: v) out.push_back(l-x); return out; } long long delivery(int N, int K, int L, int p[]) { n = N; k = K; l = L; vector <int> v1, v2; for(int i = 0;i<n;i++) { if(p[i]==0) continue; if(p[i]<L-p[i]) v1.push_back(p[i]); else v2.push_back(p[i]); } sort(v1.begin(), v1.end()); sort(v2.begin(), v2.end(), greater <int>()); return min(solve(v1, v2), solve(invertVector(v2), invertVector(v1))); //return solve(invertVector(v2), invertVector(v1)); }

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

boxes.cpp: In function 'long long int solve(std::vector<int>, std::vector<int>)':
boxes.cpp:23:38: warning: conversion from 'std::vector<int>::size_type' {aka 'long unsigned int'} to 'int' may change value [-Wconversion]
   23 |     answer = evalVector(v1, v1.size()-1) + evalVector(v2, v2.size()-1);
      |                             ~~~~~~~~~^~
boxes.cpp:23:68: warning: conversion from 'std::vector<int>::size_type' {aka 'long unsigned int'} to 'int' may change value [-Wconversion]
   23 |     answer = evalVector(v1, v1.size()-1) + evalVector(v2, v2.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...