/ SeriousOJ /

Record Detail

Time Exceeded


  
# Status Time Cost Memory Cost
#1 Time Exceeded ≥1088ms ≥320.0 KiB
#2 Time Exceeded ≥1095ms ≥532.0 KiB
#3 Time Exceeded ≥1086ms ≥532.0 KiB
#4 Time Exceeded ≥1088ms ≥532.0 KiB
#5 Time Exceeded ≥1080ms ≥548.0 KiB
#6 Time Exceeded ≥1088ms ≥320.0 KiB
#7 Time Exceeded ≥1069ms ≥324.0 KiB
#8 Time Exceeded ≥1091ms ≥324.0 KiB
#9 Time Exceeded ≥1091ms ≥436.0 KiB
#10 Time Exceeded ≥1079ms ≥532.0 KiB
#11 Time Exceeded ≥1092ms ≥532.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 <= r; ++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:55
Judged At
2024-10-03 13:02:17
Judged By
Score
0
Total Time
≥1095ms
Peak Memory
≥548.0 KiB