/ SeriousOJ /

Record Detail

Time Exceeded


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 320.0 KiB
#2 Wrong Answer 121ms 560.0 KiB
#3 Time Exceeded ≥1080ms ≥324.0 KiB
#4 Time Exceeded ≥1090ms ≥324.0 KiB
#5 Time Exceeded ≥1087ms ≥324.0 KiB
#6 Time Exceeded ≥1090ms ≥536.0 KiB
#7 Time Exceeded ≥1074ms ≥320.0 KiB
#8 Time Exceeded ≥1090ms ≥532.0 KiB
#9 Time Exceeded ≥1094ms ≥532.0 KiB
#10 Time Exceeded ≥1094ms ≥324.0 KiB
#11 Time Exceeded ≥1089ms ≥324.0 KiB

Code

#include <bits/stdc++.h>
#define int long long
#define endll '\n';
#define pb push_back
#define all(v) v.begin(), v.end()
using namespace std;

const int mod = 1e9 + 7, N = 1e6;
unordered_map<int, int> vis;

void solve()
{

   vis.clear();
   int n, k;
   cin >> n >> k;
   int L = 0, R = k / n;
   int ans = 0;
   while (L <= R)
   {
      int M = (L + R) / 2;
      int value = M, K = k - (M * n);
      if (value > K)
      {
         R = M - 1;
      }
      else
      {
         ans = max(ans, M);
         L = M + 1;
      }
   }

   for (int i = max(0LL, ans - 100); i <= ans + 100; i++)
   {
      int value = i, K = k - (i * n);
      if (K <= 0)
         continue;
      ans = max(ans, value * K);
   }

   cout << ans << endll;
}

int32_t main()
{
   ios::sync_with_stdio(false);
   cin.tie(0);
   int t = 1;
   cin >> t;
   while (t--)
   {
      solve();
   }
   return 0;
}

Information

Submit By
Type
Submission
Problem
P1092 Bitwise AND
Language
C++20 (G++ 13.2.0)
Submit At
2024-09-08 15:32:27
Judged At
2024-10-03 12:58:23
Judged By
Score
1
Total Time
≥1094ms
Peak Memory
≥560.0 KiB