QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#635726 | #9427. Collect the Coins | woodie_0064# | Compile Error | / | / | C++20 | 1.2kb | 2024-10-12 20:45:45 | 2024-10-12 20:45:47 |
Judging History
你现在查看的是最新测评结果
- [2024-11-06 15:56:27]
- hack成功,自动添加数据
- (/hack/1139)
- [2024-10-12 20:45:47]
- 评测
- 测评结果:Compile Error
- 用时:0ms
- 内存:0kb
- [2024-10-12 20:45:45]
- 提交
answer
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
const int maxn = 1e6 + 5;
const int inf = 1e9;
int n, t[maxn], c[maxn];
bool check(int v) {
function<bool(int, int)> ck = [&](int i, int j) {
if(i == 0) {
return true;
}
return (1ll * v * (t[j] - t[i])) >= 1ll * abs(c[i] - c[j]);
};
vector<int> f;
f.push_back(0);
// cout << ck(1, 3) << '\n';
for(int i = 1; i < n; i++) {
if(ck(i, i + 1)) {
continue;
}
// if(i == 2) {
// for(int j : f) {
// cout << j << ' ';
// }
// cout << '\n';
// }
bool ok = 0;
for(int j : f) {
if(ck(j, i + 1)) {
ok = 1;
break;
}
}
// if(i == 2) {
// cout << ok << "LLL\n";
// }
if(!ok) {
return 0;
}
f.clear();
f.push_back(i);
}
return 1;
}
void work(){
cin >> n;
for(int i = 1; i <= n; i++) {
cin >> t[i] >> c[i];
}
// cout << check(2) << '\n';
// cout << '\n';
// return;
int l = 0, r = inf, ans = -1;
while(l <= r) {
int mid = (l + r) / 2;
if(check(mid)) {
ans = mid;
r = mid - 1;
}
else {
l = mid + 1;
}
}
cout << ans << '\n';
}
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
int T;
cin >> T;
while(T--){
work();
}
return 0;
}
Details
answer.code: In function ‘bool check(int)’: answer.code:9:9: error: ‘function’ was not declared in this scope 9 | function<bool(int, int)> ck = [&](int i, int j) { | ^~~~~~~~ answer.code:4:1: note: ‘std::function’ is defined in header ‘<functional>’; did you forget to ‘#include <functional>’? 3 | #include <algorithm> +++ |+#include <functional> 4 | using namespace std; answer.code:9:31: error: expression list treated as compound expression in functional cast [-fpermissive] 9 | function<bool(int, int)> ck = [&](int i, int j) { | ^ answer.code:9:18: error: expected primary-expression before ‘bool’ 9 | function<bool(int, int)> ck = [&](int i, int j) { | ^~~~ answer.code:19:20: error: ‘ck’ was not declared in this scope; did you mean ‘c’? 19 | if(ck(i, i + 1)) { | ^~ | c answer.code:30:28: error: ‘ck’ was not declared in this scope; did you mean ‘ok’? 30 | if(ck(j, i + 1)) { | ^~ | ok