답안 #1003126

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1003126 2024-06-20T06:28:23 Z vjudge1 쌀 창고 (IOI11_ricehub) C++17
43 / 100
1000 ms 1884 KB
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define f first
#define s second
#define pf push_front
#define pb push_back
#define pi pair<int,int>
#define vi vector<int>

/*
int besthub(int n, int last, int x[], ll b){
    

    int ans = 0;
    int l , r;
    for(int i = 0; i < n; i++){
        
        l = i - (lower_bound(x.begin(), x.end(), max(0LL,x[i]-b))- x.begin());
        r =  upper_bound(x.begin(), x.end(), min((ll) last, x[i]+b)) - x.begin() - (i+1);
       // cout << x[i] << " " <<l << " " << r << endl;
        ans = max(l+r+1,ans);
    }
    
    return ans;

}

*/

int besthub(int n, int last, int x[], ll b){
    

    ll ans = 0;
    ll l , r;
    ll cnt;
    
    ll dl = 0, dr = 0;
    for(int i = 0; i < n; i++){
        cnt = 1;
        ll left = b;
        l = i-1,r = i+1;
        while(left && (l >= 0 || r<n)){
            dl = LLONG_MAX,dr = LLONG_MAX;
            if(l>=0) dl= x[i]-x[l];
            if(r<n )dr = x[r]-x[i];
            if(min(dl,dr)> left)break;
            if(l>= 0 && (r==n || dl <= dr)){
                left-= dl;
                
                l--;
            }
            else{
                left-= dr;
                r++;
            } 
            cnt++;
    
        }
        
       // cout << i << " ans " << cnt << endl;
        //cout << l << " " << r << endl;
       
        ans = max(ans,cnt);
         if(ans==n) return n;
    }
    
    return ans;

}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 444 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 452 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Incorrect 0 ms 348 KB Output isn't correct
11 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 3 ms 348 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 2 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 344 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 3 ms 504 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 3 ms 456 KB Output is correct
21 Correct 3 ms 600 KB Output is correct
22 Correct 5 ms 348 KB Output is correct
23 Correct 1 ms 672 KB Output is correct
24 Correct 37 ms 348 KB Output is correct
25 Correct 21 ms 344 KB Output is correct
26 Correct 75 ms 480 KB Output is correct
27 Correct 22 ms 348 KB Output is correct
28 Correct 31 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 604 KB Output is correct
2 Correct 7 ms 604 KB Output is correct
3 Correct 8 ms 1884 KB Output is correct
4 Execution timed out 1093 ms 1884 KB Time limit exceeded
5 Halted 0 ms 0 KB -