QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#400863 | #5117. Find Maximum | suibian_xiaozhao | WA | 0ms | 3648kb | C++23 | 1.2kb | 2024-04-27 17:06:21 | 2024-04-27 17:06:21 |
Judging History
answer
#include "bits/stdc++.h"
using namespace std;
#ifndef ONLINE_JUDGE
#include "test.h"
#else
#define debug(...) 42
#define debug_assert(...) 42
#endif
#define IOS ios::sync_with_stdio(0),cin.tie(0)
using ll = long long;
using ull = unsigned long long;
#define endl '\n'
#define int ll
using VI = vector<int>;
using VII = vector<VI>;
using PII = pair<int, int>;
const int inf = 1e18;
const int mod = 1e9 + 7;
void init() {
}
map<pair<int, int>, int> mp;
int get(int l, int r) {
if (l == 0 && r == 0)return 1ll;
if (l / 3 == r / 3) {
int ans = get(l / 3, r / 3) + 1 + r % 3;
if (r < 3)ans--;
return ans;
}
if (l > r)return 0ll;
int ls = get(l / 3, l / 3) + 3;
if(l<3)ls--;
int rs = get(r / 3, r / 3) +1+ r % 3;
if(r<3)rs--;
l = l / 3 + 1;
r = r / 3 - 1;
return max({ls, rs, get(l, r) +3});
}
void solve() {
int l, r;
cin >> l >> r;
int ans = get(l, r);
cout << ans << endl;
}
signed main() {
IOS;
init();
// debug(1);
int t = 1;
cin >> t;
while (t--) {
solve();
}
}
//3
// 3
// 4
// 5
// 3
// 4
// 5
// 4
// 5
// 5
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3648kb
input:
10 1 2 1 3 1 4 1 5 2 3 2 4 2 5 3 4 3 5 4 5
output:
3 4 4 5 4 4 5 4 5 5
result:
wrong answer 2nd numbers differ - expected: '3', found: '4'