제출 #668798

#제출 시각아이디문제언어결과실행 시간메모리
668798Astrayt선물상자 (IOI15_boxes)C++17
0 / 100
1 ms340 KiB
#include <bits/stdc++.h> using namespace std; #define pb push_back #define ll long long #define pii pair<int,int> #define All(x) x.begin(), x.end() ll delivery(int N, int K, int L, int pos[]){ ll ans = 0; vector<int> lp, rp; bool in_mid = 0; for(int i = 0; i < N; ++i){ if(pos[i] == L / 2 && L % 2 == 0) in_mid = 1; else if(pos[i] != 0 && pos[i] <= L / 2) lp.pb(pos[i]); else if(pos[i] > L / 2) rp.pb(pos[i]); } reverse(All(rp)); if(in_mid){ int k = K - 1; for(; k; k--){ int l = (lp.size() ? lp.back() : -1), r = (rp.size() ? rp.back() : L + 1); if(l < (L - r)) rp.pop_back(); else if(l > (L - r)) lp.pop_back(); else{ lp.pop_back(), rp.pop_back(); int nl = (lp.size() ? lp.back() : -1), nr = (rp.size() ? rp.back() : L + 1); if(nl > (L - nr)) lp.pb(l); else rp.pb(r); } } ans += L; } int cur = lp.size() + rp.size(); for(int i = cur; i >= 0; i -= K){ int k = min(K, i); int ml = 0, mr = 0; for(; k; k--){ int l, r; l = (lp.size() ? lp.back() : -1), r = (rp.size() ? rp.back() : L + 1); if(l < (L - r)) rp.pop_back(), mr = max(mr, L - r); else if(l > (L - r)) lp.pop_back(), ml = max(ml, l); else { lp.pop_back(), rp.pop_back(); int nl = (lp.size() ? lp.back() : -1), nr = (rp.size() ? rp.back() : L + 1); if(nl > (L - nr)) lp.pb(l); else rp.pb(r); } } ans += min(2 * (ml + mr), L); } return ans; }

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

boxes.cpp: In function 'long long int delivery(int, int, int, int*)':
boxes.cpp:33:22: warning: conversion from 'std::vector<int>::size_type' {aka 'long unsigned int'} to 'int' may change value [-Wconversion]
   33 |  int cur = lp.size() + rp.size();
      |            ~~~~~~~~~~^~~~~~~~~~~
#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...