제출 #333450

#제출 시각아이디문제언어결과실행 시간메모리
333450blue쌀 창고 (IOI11_ricehub)C++11
17 / 100
19 ms2540 KiB
#include "ricehub.h" #include <vector> using namespace std; int besthub(int R, int L, int X[], long long B) //fields, max coordinate, i'th field, budget { int fields = R; vector<long long> F(R+2); F[0] = -(2e15 + 1); //Change to appropriate value when budget limit is chnaged F[R+1] = (4e15 + 1); for(int i = 1; i <= R; i++) F[i] = X[i-1]; int l = 1; //leftmost field int m = 1; //hub int r = 1; //rightmost field long long c = 0; //current cost int res = 1; //running result while(1) { if(F[r+1] - F[m] + c <= B) { c += F[r+1] - F[m]; r++; } else if(m < R) {//l * * m m1 * r c += (F[m+1] - F[m]) * ((m - (l - 1)) - (r - m)); m++; while(c > B) { c -= F[m] - F[l]; l++; } } else if(F[m] - F[l] > F[r+1] - F[m]) { c -= (F[m] - F[l]); l++; } else break; res = max(res, r - l + 1); } return res; }

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

ricehub.cpp: In function 'int besthub(int, int, int*, long long int)':
ricehub.cpp:7:9: warning: unused variable 'fields' [-Wunused-variable]
    7 |     int fields = R;
      |         ^~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...