제출 #235002

#제출 시각아이디문제언어결과실행 시간메모리
235002muhammad_hokimiyon쌀 창고 (IOI11_ricehub)C++14
17 / 100
1047 ms2040 KiB
#include "ricehub.h" #include <bits/stdc++.h> using namespace std; const int N = 1e5 + 7; int n; int r1; int a[N]; long long p[N]; long long s; int f( int x ) { int l = 1 , r = n; while( l < r ){ int m = (l + r) / 2; if( a[m + 1] > x )r = m; else l = m + 1; } int res = 1; long long y = 0; for( int i = l + 1 , j = l; i <= n; i++ ){ y += 1ll * a[i] - x; l = 1 , r = j; long long cnt = 0; while( l < r ){ int m = (l + r) / 2; if( 1ll * x * (j - m + 1) - (p[j] - p[m - 1]) + y > s )l = m + 1; else r = m; } if( 1ll * x * (j - l + 1) - (p[j] - p[l - 1]) + y <= s )res = max( i - l + 1 , res ); if( y <= s )res = max( res , i - j ); } return res; } int besthub(int R, int L, int X[], long long B) { n = R; r1 = L; for( int i = 1; i <= n; i++ )a[i] = X[i - 1]; for( int i = 1; i <= n; i++ ){ p[i] = p[i - 1]; p[i] += a[i]; } s = B; int l = 1 , r = r1; while( r - l >= 1000 ){ int m1 = l + (r - l) / 3; int m2 = r - (r - l) / 3; if( f(m1) < f(m2) )l = m1; else r = m2; } int ans = f(l); for( int i = l + 1; i <= r; i++ ){ ans = max( ans , f(i) ); } return ans; }

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

ricehub.cpp: In function 'int f(int)':
ricehub.cpp:27:19: warning: unused variable 'cnt' [-Wunused-variable]
         long long cnt = 0;
                   ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...