답안 #715565

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
715565 2023-03-27T08:22:43 Z vjudge1 쌀 창고 (IOI11_ricehub) C++11
68 / 100
1000 ms 596 KB
#include <bits/stdc++.h>
#include "ricehub.h"
#define ll long long
using namespace std;

int besthub(int R, int L, int X[], long long B)
{
    int ans=0;
    for(int i=0;i<R;i++)
    {
        ll budget=B;
        int l=i,r=i+1;
        int cnt=0;
        while(l!=-1||r!=R)
        {
            if(l==-1)
            {
                if(X[r]-X[i]<=budget)
                    budget-=X[r]-X[i],r++,cnt++;
                else
                    break;
            }
            else if(r==R)
            {
                if(X[i]-X[l]<=budget)
                    budget-=X[i]-X[l],l--,cnt++;
                else
                    break;
            }
            else
            {
                int lft=X[i]-X[l],rgt=X[r]-X[i];
                int mn=min(lft,rgt);
                if(mn==lft&&lft<=budget)
                    budget-=lft,l--,cnt++;
                else if(mn==rgt&&rgt<=budget)
                    budget-=rgt,r++,cnt++;
                else
                    break;
            }
        }
        ans=max(ans,cnt);
    }
    return ans;
}
//int main()
//{
//    int a,b,d;
//    cin >> a >> b >> d;
//    int c[a];
//    for(int i=0;i<a;i++)
//        cin >> c[i];
//    cout << besthub(a,b,c,d);
//    return 0;
//}
/**
5 100 100
1 97 98 99 100
**/
# 결과 실행 시간 메모리 Grader output
1 Correct 1 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 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 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
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
26 Correct 1 ms 212 KB Output is correct
27 Correct 1 ms 212 KB Output is correct
28 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 2 ms 212 KB Output is correct
4 Correct 2 ms 340 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 280 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 ms 304 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 2 ms 212 KB Output is correct
14 Correct 2 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 3 ms 212 KB Output is correct
18 Correct 3 ms 212 KB Output is correct
19 Correct 4 ms 212 KB Output is correct
20 Correct 5 ms 212 KB Output is correct
21 Correct 4 ms 212 KB Output is correct
22 Correct 3 ms 212 KB Output is correct
23 Correct 46 ms 320 KB Output is correct
24 Correct 47 ms 308 KB Output is correct
25 Correct 85 ms 304 KB Output is correct
26 Correct 88 ms 212 KB Output is correct
27 Correct 23 ms 332 KB Output is correct
28 Correct 24 ms 312 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 340 KB Output is correct
2 Correct 4 ms 340 KB Output is correct
3 Execution timed out 1079 ms 596 KB Time limit exceeded
4 Halted 0 ms 0 KB -