답안 #36365

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
36365 2017-12-08T07:50:58 Z funcsr 쌀 창고 (IOI11_ricehub) C++14
100 / 100
29 ms 7092 KB
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include "ricehub.h"
using namespace std;
#define INF 1145141919
#define rep(i, n) for (int i=0; i<(n); i++)
#define _1 first
#define _2 second
#define all(x) x.begin(), x.end()
#define pb push_back
typedef pair<int, int> P;

int N, L;
long long B;
int X[100000];
long long T[100001];

inline long long sum(int l, int r) {
  return T[r+1] - T[l];
}
inline long long f(int l, int r) {
  int g = (l+r)/2;
  // (1LL*(g-l+1)*X[g] - sum(l, g)) + (sum(g, r) - 1LL*(r-g+1)*X[g]);
  return 1LL*(2*g-l-r)*X[g] + sum(g, r) - sum(l, g);
}

int besthub(int n, int l, int x[], long long b) {
  N = n, L = l, B = b;
  rep(i, N) X[i] = x[i];
  T[0] = 0;
  rep(i, N) T[i+1] = T[i] + X[i];
  int m = 0;
  int p = 0;
  rep(l, N) {
    while (p < N && f(l, p) <= B) p++;
    m = max(m, p-l);
  }
  return m;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 7092 KB Output is correct
2 Correct 0 ms 7092 KB Output is correct
3 Correct 0 ms 7092 KB Output is correct
4 Correct 0 ms 7092 KB Output is correct
5 Correct 0 ms 7092 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 7092 KB Output is correct
2 Correct 0 ms 7092 KB Output is correct
3 Correct 0 ms 7092 KB Output is correct
4 Correct 0 ms 7092 KB Output is correct
5 Correct 0 ms 7092 KB Output is correct
6 Correct 0 ms 7092 KB Output is correct
7 Correct 0 ms 7092 KB Output is correct
8 Correct 0 ms 7092 KB Output is correct
9 Correct 0 ms 7092 KB Output is correct
10 Correct 0 ms 7092 KB Output is correct
11 Correct 0 ms 7092 KB Output is correct
12 Correct 0 ms 7092 KB Output is correct
13 Correct 0 ms 7092 KB Output is correct
14 Correct 0 ms 7092 KB Output is correct
15 Correct 0 ms 7092 KB Output is correct
16 Correct 0 ms 7092 KB Output is correct
17 Correct 0 ms 7092 KB Output is correct
18 Correct 0 ms 7092 KB Output is correct
19 Correct 0 ms 7092 KB Output is correct
20 Correct 0 ms 7092 KB Output is correct
21 Correct 0 ms 7092 KB Output is correct
22 Correct 0 ms 7092 KB Output is correct
23 Correct 0 ms 7092 KB Output is correct
24 Correct 0 ms 7092 KB Output is correct
25 Correct 0 ms 7092 KB Output is correct
26 Correct 0 ms 7092 KB Output is correct
27 Correct 0 ms 7092 KB Output is correct
28 Correct 0 ms 7092 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 7092 KB Output is correct
2 Correct 0 ms 7092 KB Output is correct
3 Correct 0 ms 7092 KB Output is correct
4 Correct 0 ms 7092 KB Output is correct
5 Correct 0 ms 7092 KB Output is correct
6 Correct 0 ms 7092 KB Output is correct
7 Correct 0 ms 7092 KB Output is correct
8 Correct 0 ms 7092 KB Output is correct
9 Correct 0 ms 7092 KB Output is correct
10 Correct 0 ms 7092 KB Output is correct
11 Correct 0 ms 7092 KB Output is correct
12 Correct 0 ms 7092 KB Output is correct
13 Correct 0 ms 7092 KB Output is correct
14 Correct 0 ms 7092 KB Output is correct
15 Correct 0 ms 7092 KB Output is correct
16 Correct 0 ms 7092 KB Output is correct
17 Correct 0 ms 7092 KB Output is correct
18 Correct 0 ms 7092 KB Output is correct
19 Correct 0 ms 7092 KB Output is correct
20 Correct 0 ms 7092 KB Output is correct
21 Correct 0 ms 7092 KB Output is correct
22 Correct 0 ms 7092 KB Output is correct
23 Correct 0 ms 7092 KB Output is correct
24 Correct 0 ms 7092 KB Output is correct
25 Correct 0 ms 7092 KB Output is correct
26 Correct 0 ms 7092 KB Output is correct
27 Correct 0 ms 7092 KB Output is correct
28 Correct 0 ms 7092 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 7092 KB Output is correct
2 Correct 3 ms 7092 KB Output is correct
3 Correct 19 ms 7092 KB Output is correct
4 Correct 19 ms 7092 KB Output is correct
5 Correct 9 ms 7092 KB Output is correct
6 Correct 16 ms 7092 KB Output is correct
7 Correct 9 ms 7092 KB Output is correct
8 Correct 19 ms 7092 KB Output is correct
9 Correct 9 ms 7092 KB Output is correct
10 Correct 6 ms 7092 KB Output is correct
11 Correct 23 ms 7092 KB Output is correct
12 Correct 23 ms 7092 KB Output is correct
13 Correct 9 ms 7092 KB Output is correct
14 Correct 6 ms 7092 KB Output is correct
15 Correct 23 ms 7092 KB Output is correct
16 Correct 19 ms 7092 KB Output is correct
17 Correct 29 ms 7092 KB Output is correct
18 Correct 13 ms 7092 KB Output is correct
19 Correct 23 ms 7092 KB Output is correct
20 Correct 23 ms 7092 KB Output is correct