제출 #36936

#제출 시각아이디문제언어결과실행 시간메모리
36936szawinis쌀 창고 (IOI11_ricehub)C++14
100 / 100
23 ms7092 KiB
#include "ricehub.h" #include <bits/stdc++.h> using namespace std; using ll = long long; const int N = 1e5 + 1; int n, x[N]; ll limit, s[N]; int besthub(int _n, int M, int _x[], ll _limit) { n = _n, limit = _limit; copy(_x, _x + n, x + 1); for(int i = 1; i <= n; i++) s[i] = s[i-1] + x[i]; int l = 1, r = n; while (l < r) { int mid = l+r+1 >> 1; bool valid = false; // cout << mid << ":\n"; int llen = mid-1 >> 1, rlen = mid >> 1;; for(int i = llen + 1; i <= n - rlen; i++) { ll resl = 1ll * llen * x[i] - (s[i-1] - s[i - llen - 1]); ll resr = s[i + rlen] - s[i] - 1ll * rlen * x[i]; // cout << i << ' ' << resl << ' ' << resr << endl; valid |= resl + resr <= limit; } if (valid) l = mid; else r = mid - 1; } return l; }

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

ricehub.cpp: In function 'int besthub(int, int, int*, ll)':
ricehub.cpp:16:18: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
     int mid = l+r+1 >> 1;
                  ^
ricehub.cpp:19:19: warning: suggest parentheses around '-' inside '>>' [-Wparentheses]
     int llen = mid-1 >> 1, rlen = mid >> 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...