QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#732500 | #8777. Passport Stamps | jiujiu# | WA | 4ms | 4820kb | C++20 | 1.1kb | 2024-11-10 14:53:46 | 2024-11-10 14:53:48 |
Judging History
answer
#include <bits/stdc++.h>
using ld = long double;
using i64 = long long;
#define NO std::cout << "No\n"
#define YES std::cout << "Yes\n"
#define all(x) x.begin(), x.end()
// std::default_random_engine Rand;
// std::uniform_int_distribution<int> r1(1, 10);
// constexpr int d[4][2] = {-1, 0, 0, 1, 1, 0, 0, -1};
void solve() {
i64 n, p;
std::cin >> n >> p;
std::vector<i64> v(n + 1), sum(n + 1);
for(int i = 1; i <= n; i++){
std::cin >> v[i];
sum[i] = sum[i - 1] + v[i];
}
auto f = [&](i64 x){
i64 s = sum[x - 1];
s += (x - 1) * (v[x] - 1);
return p - s < v[x];
};
i64 l = 0, r = n + 1;
while(l + 1 != r){
i64 m = (l + r) >> 1;
if(f(m)){
r = m;
} else {
l = m;
}
}
std::cout << l << "\n";
}
int main() {
std::ios::sync_with_stdio(false);
std::cin.tie(0);
std::cout.tie(0);
// Rand.seed(time(0));
int _ = 1;
// std::cin >> _;
// scanf("%ld",&_);
// std::cout<<std::fixed<<std::setprecision(2);
while (_--) {
solve();
}
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3860kb
input:
5 15 1 2 3 4 5
output:
3
result:
ok single line: '3'
Test #2:
score: 0
Accepted
time: 3ms
memory: 4820kb
input:
100000 559309580160692839 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...
output:
84437
result:
ok single line: '84437'
Test #3:
score: -100
Wrong Answer
time: 4ms
memory: 4780kb
input:
100000 890934113082207108 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...
output:
100000
result:
wrong answer 1st lines differ - expected: '53636', found: '100000'