답안 #289417

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
289417 2020-09-02T16:10:39 Z BeanZ 쌀 창고 (IOI11_ricehub) C++14
17 / 100
20 ms 1792 KB
#include <bits/stdc++.h>
#include "ricehub.h"

using namespace std;

#define ll long long
#define endl '\n'
const int N = 1e5 + 5;
int besthub(int r, int l, int x[], ll b){
        ll lf = 1, rt = 1;
        ll cur = 0, ans = 0;
        while (rt < r && (cur + (x[rt] - x[0])) <= b){
                cur = cur + (x[rt] - x[0]);
                rt++;
        }
        ans = max(ans, rt - lf + 1);
        //cout << cur << " " << lf << " " << rt << endl;
        for (int i = 2; i <= r; i++){
                cur = cur - (rt - i + 1) * (x[i - 1] - x[i - 2]);
                cur = cur + (i - lf) * (x[i - 1] - x[i - 2]);
                while (cur > b){
                        cur = cur - (x[i - 1] - x[lf - 1]);
                        lf++;
                }
                while (rt < r && (cur + x[rt] - x[i - 1]) <= b){
                        cur = cur + x[rt] - x[i - 1];
                        rt++;
                }
                while (lf > 1 && (cur + x[i - 1] - x[lf - 2]) <= b){
                        cur = cur + x[i - 1] - x[lf - 2];
                        lf--;
                }
                //cout << cur << " " << lf << " " << rt << endl;
                ans = max(ans, rt - lf + 1);
        }
        return ans;
}
/*
ll x[N];
int main(){
        ios_base::sync_with_stdio(false);
        cin.tie(0);
        if (fopen("time.in", "r")){
                freopen("time.in", "r", stdin);
                freopen("time.out", "w", stdout);
        }
        ll r, l, b;
        cin >> r >> l >> b;
        for (int i = 1; i <= r; i++) cin >> x[i - 1];
        ll lf = 1, rt = 1;
        ll cur = 0, ans = 0;
        while (rt < r && (cur + (x[rt] - x[0])) <= b){
                cur = cur + (x[rt] - x[0]);
                rt++;
        }
        ans = max(ans, rt - lf + 1);
        //cout << cur << " " << lf << " " << rt << endl;
        for (int i = 2; i <= r; i++){
                cur = cur - (rt - i + 1) * (x[i - 1] - x[i - 2]);
                cur = cur + (i - lf) * (x[i - 1] - x[i - 2]);
                while (cur > b){
                        cur = cur - (x[i - 1] - x[lf - 1]);
                        lf++;
                }
                while (rt < r && (cur + x[rt] - x[i - 1]) <= b){
                        cur = cur + x[rt] - x[i - 1];
                        rt++;
                }
                while (lf > 1 && (cur + x[i - 1] - x[lf - 2]) <= b){
                        cur = cur + x[i - 1] - x[lf - 2];
                        lf--;
                }
                //cout << cur << " " << lf << " " << rt << endl;
                ans = max(ans, rt - lf + 1);
        }
        cout << ans;
}
/*
*/

Compilation message

ricehub.cpp:78:1: warning: "/*" within comment [-Wcomment]
   78 | /*
      |
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 256 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 1 ms 256 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Correct 0 ms 256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 1 ms 256 KB Output is correct
4 Correct 0 ms 256 KB Output is correct
5 Correct 1 ms 256 KB Output is correct
6 Correct 0 ms 256 KB Output is correct
7 Correct 0 ms 256 KB Output is correct
8 Correct 1 ms 256 KB Output is correct
9 Correct 0 ms 256 KB Output is correct
10 Correct 0 ms 256 KB Output is correct
11 Correct 1 ms 256 KB Output is correct
12 Correct 0 ms 256 KB Output is correct
13 Correct 1 ms 384 KB Output is correct
14 Incorrect 1 ms 256 KB Output isn't correct
15 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 0 ms 384 KB Output is correct
6 Correct 1 ms 256 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 1 ms 384 KB Output is correct
10 Correct 1 ms 256 KB Output is correct
11 Correct 1 ms 384 KB Output is correct
12 Correct 1 ms 416 KB Output is correct
13 Correct 1 ms 384 KB Output is correct
14 Correct 1 ms 384 KB Output is correct
15 Incorrect 1 ms 384 KB Output isn't correct
16 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 384 KB Output is correct
2 Correct 3 ms 512 KB Output is correct
3 Correct 20 ms 1784 KB Output is correct
4 Correct 19 ms 1792 KB Output is correct
5 Correct 7 ms 896 KB Output is correct
6 Correct 7 ms 896 KB Output is correct
7 Correct 14 ms 1536 KB Output is correct
8 Correct 14 ms 1536 KB Output is correct
9 Correct 8 ms 768 KB Output is correct
10 Correct 7 ms 768 KB Output is correct
11 Correct 18 ms 1784 KB Output is correct
12 Correct 18 ms 1792 KB Output is correct
13 Incorrect 8 ms 896 KB Output isn't correct
14 Halted 0 ms 0 KB -