QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#752933 | #5593. Food Processor | anyan26 | RE | 0ms | 4028kb | C++17 | 1.0kb | 2024-11-16 10:30:42 | 2024-11-16 10:30:42 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
double nxt(double size, double want, double div2){
return (log2(size) - log2(want)) * (double)div2;
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
//sort by t
double s, t;int n; cin >> s >> t >> n;
pair<double, double> process[n];
double mxblade = 0;
for(int i = 0; i < n; i++){ //hour, blade size
cin >> process[i].second >> process[i].first;
mxblade = max(mxblade, process[i].second);
}
sort(process, process+n);
int cur = n;
if(mxblade < s){
cout << "-1\n";
return -1;
}
double ret = 0; bool can = false;
while (s > t){
while(cur > 0 && process[cur-1].second >= s)cur--;
can = true;
int goal = t;
if(cur != 0)goal = process[cur-1].second;
ret += nxt(s, goal, process[cur].first);
s = goal;
}
cout << fixed << setprecision(10) << ret << "\n";
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3964kb
input:
10 1 2 10 10 4 5
output:
23.2192809489
result:
ok found '23.21928', expected '23.21928', error '0.00000'
Test #2:
score: 0
Accepted
time: 0ms
memory: 4028kb
input:
10000 9999 1 10000 1
output:
0.0001442767
result:
ok found '0.00014', expected '0.00014', error '0.00000'
Test #3:
score: -100
Runtime Error
input:
10 1 2 8 10 4 5
output:
-1