답안 #725904

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
725904 2023-04-18T08:39:26 Z adrilen 쌀 창고 (IOI11_ricehub) C++17
0 / 100
14 ms 2892 KB
#include "ricehub.h"
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
typedef pair<int, int> pii;





int besthub(int n, int L, int X[], long long b)
{
    vector <ll> fields;
    for (int i = 0; i < n; i++) fields.emplace_back(X[i]);

    auto lt = fields.begin(), pos = fields.begin(), rt = fields.begin() + 1;
    ll left, right;
    left = right = 0;
    ll cur = 0;
    ll output = 0;

    if (n == 1) return 1;

    while (rt != fields.end())
    {

        while (b < cur)
        {
            // cout << *pos << " " << *lt << " " << cur << endl;
            cur -= *pos - *lt;
            lt++, left--;
        }

        while (rt != fields.end() && cur + *rt - *pos <= b)
        {   
            cur += *rt - *pos;
            right++, rt++;
        }

        while (rt != fields.end() && (*pos - *lt) > (*rt - *pos))
        {
            left--, right++, lt++, rt++;
            while (rt != fields.end() && cur + *rt - *pos <= b)
            {   
                cur += *rt - *pos;
                right++, rt++;
            }
        }

        // cout << lt - fields.begin() << " " << pos - fields.begin() << " " << rt - fields.begin() << " " << cur << " " << left << " " << right << endl;
        output = max(output, left + right + 1);

        if (pos + 1 != fields.end()) {
            // cout << cur << " ";
            cur += (*(pos + 1) - *pos) * (left + 1);
            // cout << cur << " ";
            cur += (*pos - *(pos + 1)) * (right);
            // cout << cur << endl;
        }
        pos++, left++, right--;

    }
    // cerr << output << "\n";
    return output;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 1 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 312 KB Output is correct
4 Correct 1 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 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 308 KB Output is correct
17 Correct 1 ms 316 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Incorrect 1 ms 212 KB Output isn't correct
20 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 312 KB Output is correct
6 Correct 0 ms 312 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 308 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 316 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Incorrect 0 ms 212 KB Output isn't correct
16 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 852 KB Output is correct
2 Correct 3 ms 836 KB Output is correct
3 Correct 12 ms 2872 KB Output is correct
4 Correct 12 ms 2892 KB Output is correct
5 Correct 5 ms 1468 KB Output is correct
6 Correct 6 ms 1488 KB Output is correct
7 Correct 13 ms 2628 KB Output is correct
8 Correct 11 ms 2748 KB Output is correct
9 Correct 5 ms 1444 KB Output is correct
10 Correct 6 ms 1344 KB Output is correct
11 Correct 13 ms 2892 KB Output is correct
12 Correct 14 ms 2820 KB Output is correct
13 Incorrect 7 ms 1524 KB Output isn't correct
14 Halted 0 ms 0 KB -