/ SeriousOJ /

Record Detail

Time Exceeded


  
# Status Time Cost Memory Cost
#1 Time Exceeded ≥1092ms ≥488.0 KiB
#2 Time Exceeded ≥1090ms ≥320.0 KiB

Code

// not my code

#include <bits/stdc++.h>
using namespace std;

#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
using ll = long long;

ll get_ans(ll n, ll k) {
  ll i, t, l, r, mid1, mid2, ans1, ans2, ans;

  l = 0; r = (k+n-1)/n;
  t = 100; while (l < r) {
    mid1 = l + (r-l)/3;
    mid2 = r - (r-l)/3;
    ans1 = mid1 * (k - mid1*n);
    ans2 = mid2 * (k - mid2*n);
    if (ans1 > ans2) {
      r = mid2;
    } else {
      l = mid1;
    }
  }

  ans = 0;
  for (i = l; i <= l; ++i) {
    ans = max(ans, i * (k - i*n));
  }

  return ans;
}

int main() {
  FAST;
  
  int tc = 1, ti;
  cin >> tc;

  for (ti = 1; ti <= tc; ++ti) {
    ll n, k;
    cin >> n >> k;
    cout << get_ans(n, k) << "\n";
  }

  return 0;
}

Information

Submit By
Type
Submission
Problem
P1092 Bitwise AND
Language
C++20 (G++ 13.2.0)
Submit At
2024-09-05 19:02:47
Judged At
2024-11-11 02:57:19
Judged By
Score
0
Total Time
≥1092ms
Peak Memory
≥488.0 KiB