답안 #715563

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
715563 2023-03-27T08:21:03 Z cbup 쌀 창고 (IOI11_ricehub) C++14
17 / 100
438 ms 262144 KB
#include<bits/stdc++.h>
using namespace std;

long long besthub(int n,int l,int x[],long long b){
    long long cost,ans=0;
    int mid;
    vector<long long> prefixSum(l,0);

    for(int i=1;i<=n;i++)prefixSum[i] = prefixSum[i-1]+x[i-1];
    //for(int i=1;i<=n;i++)cout<<prefixSum[i]<<" "; cout<<endl;
    for(int st=0;st<n;st++){
        for(int en=st;en<n;en++){
            mid = (st+en)/2;
            cost = (mid-st)*x[mid]*1LL-(prefixSum[mid]-prefixSum[st]) + (prefixSum[en+1]-prefixSum[mid+1])-(en-mid)*x[mid]*1LL;

            if(cost <= b)ans = max(ans,en-st+1LL);
            //cout<<st<<" "<<en<<" "<<cost<<endl;
        }
    }
    return ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Runtime error 1 ms 340 KB Execution killed with signal 6
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 4 ms 7636 KB Output is correct
4 Correct 5 ms 7636 KB Output is correct
5 Runtime error 1 ms 468 KB Execution killed with signal 6
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 438 ms 1148 KB Output is correct
2 Correct 437 ms 1108 KB Output is correct
3 Runtime error 104 ms 262144 KB Execution killed with signal 9
4 Halted 0 ms 0 KB -