제출 #668855

#제출 시각아이디문제언어결과실행 시간메모리
668855Astrayt선물상자 (IOI15_boxes)C++17
35 / 100
1 ms212 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, L = _L; vector<ll> lp, rp; for(int i = 0; i < N; ++i){ 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)); int cur = lp.size() + rp.size(); for(; (int)(lp.size()) + (int)(rp.size()) > 0;){ int k = min(K, (int)(lp.size()) + (int)(rp.size())); ll ml = 0, mr = 0; for(; k; k--){ ll l, r; l = (lp.size() ? lp.back() : -1), r = (rp.size() ? rp.back() : L + 1); if(ml == 0 && mr == 0){ if(l > (L - r)) ml = l, lp.pop_back(); else mr = (L - r), rp.pop_back(); }else if(ml && l >= (L - r)) lp.pop_back(); else if(mr && (L - r) >= l) rp.pop_back(); else{ if (ml && 2ll * (ml + L - r) < L){ while(k && lp.size()) lp.pop_back(), k--; break; } else if(ml && r != L + 1){ mr = L - r; rp.pop_back(); }else if(mr && 2ll * (mr + l) < L){ while(k && rp.size()) rp.pop_back(), k--; break; } else if(mr && l != -1){ ml = l; lp.pop_back(); } } } ans += min(2ll * (ml + mr), 1ll * L); } return ans; }

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

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