Submission #5991151


Source Code Expand

#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>
#include <functional>
#include <bitset>
#include <cstdint>

using namespace std;
using i64 = int64_t;
using i32 = int32_t;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (size_t i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (size_t i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

template<class F>
i64 bisect(i64 l, i64 r, F f) { // (l, r]
  if (r - l <= 1) return r;
  i64 m = l + (r - l) / 2;
  return f(m) ? bisect(l, m, f) : bisect(m, r, f);
}

i64 n, k;
vector<i64> w, d;
int main() {
  cin >> n >> k;
  init_n(w, n);
  init_n(d, n);
  for (i64 i = 0; i < n; ++i) {
    cin >> w[i] >> d[i];
  }
  
  i64 ans = bisect(0, 1ll << 62, [&](i64 x) {
    i64 c = 0;
    for (i64 i = 0; i < n; ++i) {
      c += max(i64(0), (x - w[i]) / d[i] + 1);
    }
    return c >= k;
  });

  cout << ans << '\n';
  return 0;
}

Submission Info

Submission Time
Task C - Garden
User cottoncotton
Language C++14 (GCC 5.4.1)
Score 0
Code Size 1460 Byte
Status WA
Exec Time 216 ms
Memory 1792 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 100
Status
AC × 3
AC × 22
WA × 1
Set Name Test Cases
Sample a01, a02, a03
All a01, a02, a03, b04, b05, b06, b07, b08, b09, b10, b11, b12, b13, b14, b15, b16, b17, b18, b19, b20, b21, b22, b23
Case Name Status Exec Time Memory
a01 AC 1 ms 256 KB
a02 AC 1 ms 256 KB
a03 AC 1 ms 256 KB
b04 AC 1 ms 256 KB
b05 AC 216 ms 1792 KB
b06 WA 198 ms 1792 KB
b07 AC 211 ms 1792 KB
b08 AC 215 ms 1792 KB
b09 AC 211 ms 1792 KB
b10 AC 212 ms 1792 KB
b11 AC 210 ms 1792 KB
b12 AC 202 ms 1792 KB
b13 AC 198 ms 1792 KB
b14 AC 197 ms 1792 KB
b15 AC 210 ms 1792 KB
b16 AC 202 ms 1792 KB
b17 AC 202 ms 1792 KB
b18 AC 197 ms 1792 KB
b19 AC 195 ms 1792 KB
b20 AC 193 ms 1792 KB
b21 AC 191 ms 1792 KB
b22 AC 194 ms 1792 KB
b23 AC 191 ms 1792 KB