답안 #556477

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
556477 2022-05-03T08:37:45 Z Dan4Life 쌀 창고 (IOI11_ricehub) C++17
0 / 100
2 ms 468 KB
#include "ricehub.h"
#include <bits/stdc++.h>
using namespace std;
#define ll long long

ll pref[100010];

ll sum(int i, int j){ return pref[j+1]-pref[i]; }

int besthub(int n, int m, int a[], ll b)
{
    pref[0] = 0; int ans = 0;
    for(int i = 0; i < n; i++)
        pref[i+1] = pref[i]+a[i];
    for(int i = 0; i < n; i++){
        int l = i, r = n-1;
        while(l<r){
            int mid = (l+r+1)/2;
            int x = (i+mid+1)/2, xx = (i+mid-1)/2;
            if(sum(x,mid)-sum(i,x-1)<=b) l=mid;
            else r = mid-1;
        }
        ans = max(ans, l-i+1);
    }
    return ans;
}

Compilation message

ricehub.cpp: In function 'int besthub(int, int, int*, long long int)':
ricehub.cpp:19:34: warning: unused variable 'xx' [-Wunused-variable]
   19 |             int x = (i+mid+1)/2, xx = (i+mid-1)/2;
      |                                  ^~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 0 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Incorrect 1 ms 212 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 0 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 468 KB Output is correct
2 Incorrect 2 ms 468 KB Output isn't correct
3 Halted 0 ms 0 KB -