Submission #7340489


Source Code Expand

Copy
#include <iostream>
#include <vector>

using namespace std;  

typedef long long ll;

bool judge(ll k, int n, int a, int b, vector<int> h) {
  ll sum = 0;
  for (int i = 0; i < n; i++) {
    ll t = h[i] - k*b;
    if (t > 0) {
      sum += (t+a-b-1) / (a-b);
      if (sum > k) { return false; }
    }
  }
  return true;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  int n, a, b;
  cin >> n >> a >> b;

  vector<int> h(n);

  for (int i = 0; i < n; i++) {
    cin >> h[i];
  }

  ll low = 0, high = (ll)1e9+9;

  while (low < high) {
    ll mid = (low + high) / 2;
    if (judge(mid, n, a, b, h)) {
      high = mid;
    } else {
      low = mid+1;
    }
  }

  cout << low << endl;

  return 0;
}

Submission Info

Submission Time
Task D - Widespread
User kira924age
Language C++14 (GCC 5.4.1)
Score 400
Code Size 761 Byte
Status
Exec Time 38 ms
Memory 1024 KB

Test Cases

Set Name Score / Max Score Test Cases
Sample 0 / 0 a01, a02, a03
All 400 / 400 a01, a02, a03, b04, b05, b06, b07, b08, b09, b10, b11, b12, b13
Case Name Status Exec Time Memory
a01 1 ms 256 KB
a02 1 ms 256 KB
a03 1 ms 256 KB
b04 1 ms 256 KB
b05 14 ms 1024 KB
b06 29 ms 1024 KB
b07 24 ms 1024 KB
b08 23 ms 1024 KB
b09 14 ms 1024 KB
b10 14 ms 1024 KB
b11 15 ms 1024 KB
b12 16 ms 1024 KB
b13 38 ms 1024 KB