QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#519600 | #4682. Pipe Stream | PetroTarnavskyi | WA | 0ms | 3708kb | C++23 | 1.3kb | 2024-08-14 22:02:14 | 2024-08-14 22:02:15 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define RFOR(i, a, b) for(int i = (a) - 1; i >= (b); i--)
#define SZ(a) int(a.size())
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair
#define F first
#define S second
typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;
typedef double db;
void solve()
{
int l, v1, v2, t, s;
cin >> l >> v1 >> v2 >> t >> s;
int k = 0;
while((1LL << k) * t < v2 - v1)
k++;
if(k <= (l / (v2 * (LL)s)))
{
cout << k << "\n";
return;
}
int ans = 0;
int cnt = 0;
while(v2 - v1 > t)
{
auto check = [&](int num)
{
if(num > 30 || v2 <= t * (1LL << num))
return false;
FOR(i, 0, num)
{
int v = v2 - t * (1 << (num - 1 - i));
if(cnt + i + 1 > l / (v * s))
return false;
}
return true;
};
if(!check(1))
{
cout << "impossible\n";
return;
}
int mx = 1;
while(check(mx)) mx++;
mx--;
k = mx;
v2 = v2 - t * (1 << (k - 1));
//cerr << cnt << " " << mx << " " << v2 << "\n";
ans = max(ans, cnt + mx);
cnt++;
}
cout << ans << "\n";
}
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
int t;
cin >> t;
while(t--)
solve();
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3708kb
input:
3 1000 1 30 1 1 60 2 10 2 5 59 2 10 2 5
output:
5 3 impossible
result:
ok 3 lines
Test #2:
score: -100
Wrong Answer
time: 0ms
memory: 3656kb
input:
100 1 1 2 1 1 1 1 3 1 1 2 1 3 1 1 3 1 4 1 1 4 1 4 1 1 100000 1 1000000 1 1 100000 1 9 1 1 100000 1 9454 1 1 100000 1 9455 1 1 500832 1 40181 1 1 500832 1 40182 1 1 524288 1 41871 1 1 524288 1 41872 1 1 930168 1 70677 1 1 930168 1 70678 1 1 930169 1 70677 1 1 930169 1 70678 1 1 930170 1 70677 1 1 930...
output:
0 impossible 1 impossible 2 impossible 3 impossible impossible impossible impossible impossible impossible impossible impossible impossible impossible impossible impossible impossible impossible impossible impossible impossible 3 3 impossible impossible 0 0 impossible impossible impossible impossibl...
result:
wrong answer 8th lines differ - expected: '24', found: 'impossible'