답안 #335943

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
335943 2020-12-14T11:08:28 Z aryan12 쌀 창고 (IOI11_ricehub) C++17
68 / 100
1000 ms 1516 KB
#include <bits/stdc++.h>
#include "ricehub.h"
using namespace std;

int besthub(int r, int l, int x[], long long b) {
    long long ans = 1;
    for(long long i = 2; i <= r; i++) {
        long long left = 1, right = i, best = r;
        long long mid;
        while(left <= right) {
            mid = (left + right) / 2;
            long long FieldSituated = (mid + i) / 2, cost = 0;
            //cout << "left = " << left << ", right = " << right << ", mid = " << mid << ", FieldSituated = " << FieldSituated << ", cost = ";
            for(long long j = mid; j <= i; j++) {
                cost += (abs(x[j] - x[FieldSituated]));
            }
            //cout << cost << endl;
            if(cost <= b) {
                right = mid - 1;
                best = mid;
            }
            else {
                left = mid + 1;
            }
        }
        ans = max(ans, i - best + 1);
    }
    int lol = ans;
    return lol;
}

/*int main() {
    cout << "Input the number of rice fields" << endl;
    int r;
    cin >> r;
    cout << "Input the maximum coordinate" << endl;
    int l;
    cin >> l;
    cout << "Input r numbers, denoting the rice fields" << endl;
    int x[r + 1];
    for(int i = 1; i <= r; i++) {
        cin >> x[i];
    }
    cout << "Input the budget" << endl;
    int b;
    cin >> b;
    cout << besthub(r, l, x, b) << endl;
}
*/
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
16 Correct 1 ms 364 KB Output is correct
17 Correct 1 ms 364 KB Output is correct
18 Correct 1 ms 364 KB Output is correct
19 Correct 1 ms 364 KB Output is correct
20 Correct 1 ms 364 KB Output is correct
21 Correct 1 ms 364 KB Output is correct
22 Correct 2 ms 364 KB Output is correct
23 Correct 1 ms 364 KB Output is correct
24 Correct 2 ms 364 KB Output is correct
25 Correct 2 ms 364 KB Output is correct
26 Correct 1 ms 364 KB Output is correct
27 Correct 1 ms 364 KB Output is correct
28 Correct 2 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 4 ms 364 KB Output is correct
4 Correct 4 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 2 ms 364 KB Output is correct
8 Correct 2 ms 384 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 2 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 5 ms 364 KB Output is correct
14 Correct 4 ms 364 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
16 Correct 1 ms 364 KB Output is correct
17 Correct 3 ms 364 KB Output is correct
18 Correct 3 ms 364 KB Output is correct
19 Correct 5 ms 364 KB Output is correct
20 Correct 5 ms 364 KB Output is correct
21 Correct 21 ms 364 KB Output is correct
22 Correct 21 ms 364 KB Output is correct
23 Correct 121 ms 364 KB Output is correct
24 Correct 121 ms 364 KB Output is correct
25 Correct 129 ms 492 KB Output is correct
26 Correct 125 ms 364 KB Output is correct
27 Correct 101 ms 364 KB Output is correct
28 Correct 106 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 210 ms 620 KB Output is correct
2 Correct 207 ms 492 KB Output is correct
3 Execution timed out 1065 ms 1516 KB Time limit exceeded
4 Halted 0 ms 0 KB -