QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#823340 | #9061. Streets Behind | LaVuna47 | WA | 17ms | 3700kb | C++17 | 1.8kb | 2024-12-20 22:10:35 | 2024-12-20 22:10:36 |
Judging History
answer
/** gnu specific **/
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
/** contains everything I need in std **/
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(S) ((int)S.size())
#define FOR(i, st_, n) for(int i = st_; i < n; ++i)
#define RFOR(i, n, end_) for(int i = (n)-1; i >= end_; --i)
#define x first
#define y second
#define pb push_back
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef unsigned long long ull;
typedef long double LD;
typedef pair<ull, ull> pull;
using namespace __gnu_pbds;
typedef tree<ll, null_type, less<>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
using namespace std;
#ifdef ONPC
mt19937 rnd(228);
#else
mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());
#endif
int solve()
{
ll n,k,a,b;
if(!(cin>>n>>k>>a>>b))return 1;
if(b*n < a*(n+1))
{
cout<<"-1\n";
return 0;
}
ll y=(n*b-a*n)/a;
ll res=0;
for(; k > 0;++y)
{
ll x = (a*n + y*a + a - n*b + (b*y - y*a-1)) / (b*y - y*a);
if(k-y*x < 0)
{
res += (k+y-1)/(y);
break;
}
else
{
if(x==0)
{
++res;
break;
}
res += x;
k -= y*x;
n += y*x;
}
}
cout<<res<<'\n';
return 0;
}
int32_t main()
{
ios::sync_with_stdio(0);
cin.tie(0);
int TET = 1e9;
cin >> TET;
for (int i = 1; i <= TET; i++)
{
if (solve())
{
break;
}
#ifdef ONPC
cout << "__________________________" << endl;
#endif
}
#ifdef ONPC
cerr << endl << "finished in " << clock() * 1.0 / CLOCKS_PER_SEC << " sec" << endl;
#endif
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3544kb
input:
3 9 5 5 6 2 7 1 8 3 4 1 5
output:
3 1 1
result:
ok 3 lines
Test #2:
score: 0
Accepted
time: 0ms
memory: 3592kb
input:
54 1 1 1 1 1 1 1 2 1 1 1 3 1 1 2 2 1 1 2 3 1 1 3 3 1 2 1 1 1 2 1 2 1 2 1 3 1 2 2 2 1 2 2 3 1 2 3 3 1 3 1 1 1 3 1 2 1 3 1 3 1 3 2 2 1 3 2 3 1 3 3 3 2 1 1 1 2 1 1 2 2 1 1 3 2 1 2 2 2 1 2 3 2 1 3 3 2 2 1 1 2 2 1 2 2 2 1 3 2 2 2 2 2 2 2 3 2 2 3 3 2 3 1 1 2 3 1 2 2 3 1 3 2 3 2 2 2 3 2 3 2 3 3 3 3 1 1 1 3...
output:
-1 1 1 -1 -1 -1 -1 2 1 -1 -1 -1 -1 2 2 -1 -1 -1 -1 1 1 -1 1 -1 -1 1 1 -1 2 -1 -1 2 1 -1 3 -1 -1 1 1 -1 1 -1 -1 1 1 -1 2 -1 -1 1 1 -1 2 -1
result:
ok 54 lines
Test #3:
score: 0
Accepted
time: 0ms
memory: 3552kb
input:
54 10 10 10 10 10 10 10 11 10 10 10 12 10 10 11 11 10 10 11 12 10 10 12 12 10 11 10 10 10 11 10 11 10 11 10 12 10 11 11 11 10 11 11 12 10 11 12 12 10 12 10 10 10 12 10 11 10 12 10 12 10 12 11 11 10 12 11 12 10 12 12 12 11 10 10 10 11 10 10 11 11 10 10 12 11 10 11 11 11 10 11 12 11 10 12 12 11 11 10 ...
output:
-1 10 5 -1 -1 -1 -1 11 5 -1 -1 -1 -1 11 5 -1 -1 -1 -1 10 4 -1 10 -1 -1 10 5 -1 11 -1 -1 11 5 -1 12 -1 -1 9 4 -1 10 -1 -1 10 5 -1 11 -1 -1 10 5 -1 11 -1
result:
ok 54 lines
Test #4:
score: 0
Accepted
time: 0ms
memory: 3608kb
input:
54 4 4 4 4 4 4 4 5 4 4 4 6 4 4 5 5 4 4 5 6 4 4 6 6 4 5 4 4 4 5 4 5 4 5 4 6 4 5 5 5 4 5 5 6 4 5 6 6 4 6 4 4 4 6 4 5 4 6 4 6 4 6 5 5 4 6 5 6 4 6 6 6 5 4 4 4 5 4 4 5 5 4 4 6 5 4 5 5 5 4 5 6 5 4 6 6 5 5 4 4 5 5 4 5 5 5 4 6 5 5 5 5 5 5 5 6 5 5 6 6 5 6 4 4 5 6 4 5 5 6 4 6 5 6 5 5 5 6 5 6 5 6 6 6 6 4 4 4 6...
output:
-1 4 2 -1 -1 -1 -1 5 2 -1 -1 -1 -1 5 3 -1 -1 -1 -1 4 2 -1 4 -1 -1 4 2 -1 5 -1 -1 5 3 -1 6 -1 -1 3 2 -1 4 -1 -1 4 2 -1 5 -1 -1 4 2 -1 5 -1
result:
ok 54 lines
Test #5:
score: 0
Accepted
time: 0ms
memory: 3700kb
input:
54 7 7 7 7 7 7 7 8 7 7 7 9 7 7 8 8 7 7 8 9 7 7 9 9 7 8 7 7 7 8 7 8 7 8 7 9 7 8 8 8 7 8 8 9 7 8 9 9 7 9 7 7 7 9 7 8 7 9 7 9 7 9 8 8 7 9 8 9 7 9 9 9 8 7 7 7 8 7 7 8 8 7 7 9 8 7 8 8 8 7 8 9 8 7 9 9 8 8 7 7 8 8 7 8 8 8 7 9 8 8 8 8 8 8 8 9 8 8 9 9 8 9 7 7 8 9 7 8 8 9 7 9 8 9 8 8 8 9 8 9 8 9 9 9 9 7 7 7 9...
output:
-1 7 3 -1 -1 -1 -1 8 4 -1 -1 -1 -1 8 4 -1 -1 -1 -1 7 3 -1 7 -1 -1 7 4 -1 8 -1 -1 8 4 -1 9 -1 -1 6 3 -1 7 -1 -1 7 3 -1 8 -1 -1 7 3 -1 8 -1
result:
ok 54 lines
Test #6:
score: -100
Wrong Answer
time: 17ms
memory: 3532kb
input:
100 87279562 988175500 990523511 990564829 87279562 988175500 990523511 990564829 87279562 988175500 990523511 990564829 87279562 988175500 990523511 990564829 87279562 988175500 990523511 990564829 87279562 988175500 990523511 990564829 87279562 988175500 990523511 990564829 87279562 988175500 9905...
output:
45260 45260 45260 45260 45260 45260 45260 45260 45260 45260 45260 45260 45260 45260 45260 45260 45260 45260 45260 45260 45260 45260 45260 45260 45260 45260 45260 45260 45260 45260 45260 45260 45260 45260 45260 45260 45260 45260 45260 45260 45260 45260 45260 45260 45260 45260 45260 45260 45260 45260 ...
result:
wrong answer 1st lines differ - expected: '60211', found: '45260'