QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#90912 | #1299. Jinxed Betting | hippotumux | WA | 3ms | 3488kb | C++14 | 1.0kb | 2023-03-26 02:40:10 | 2023-03-26 02:40:13 |
Judging History
answer
#include <bits/stdc++.h>
#define ll long long
#define inf int(1e8)
#define lnf ll(1e18)
#define pair<int,int> pii;
#define fastio ios::sync_with_stdio(false),cin.tie(0)
using namespace std;
vector<ll> vec;
ll n, tar;
int SUM (ll target) {
ll sum = 0;
for (auto it : vec) {
if (tar < it + target) sum += it + target - tar;
if (sum > target) return 0;
}
if (sum == target) return 2;
return 1;
}
void solve(){
cin >> n;
cin >> tar;
vec.resize(n-1);
int times = 0;
for (int i = 0 ; i < n - 1; i++) cin >> vec[i];
for (auto it : vec) {
if (it == tar) times ++;
}
if (times >= 2) {
cout << 0 << '\n';
return;
}
ll l = 1, r = 1e17;
while (l < r) {
ll mid = (l + r + 1)/2;
if (SUM(mid)) l = mid;
else r = mid - 1;
}
ll mid = (l + r)/2;
ll ans;
ll k = 1;
for (ll i = max(k,mid - 10); i <= mid + 10 ; i++) {
if (SUM(i) == 2){
cout << i << '\n';
return ;
}else if(SUM(i) == 1){
ans = i;
}else break;
}
cout << ans << '\n';
}
int main(void) {
fastio;
solve();
}
详细
Test #1:
score: 100
Accepted
time: 3ms
memory: 3376kb
input:
3 23 23 23
output:
0
result:
ok single line: '0'
Test #2:
score: 0
Accepted
time: 2ms
memory: 3488kb
input:
3 9999999999999997 99999977 42
output:
19999999899999975
result:
ok single line: '19999999899999975'
Test #3:
score: -100
Wrong Answer
time: 0ms
memory: 3356kb
input:
5 10 3 3 3 3
output:
9
result:
wrong answer 1st lines differ - expected: '10', found: '9'