QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#752933#5593. Food Processoranyan26RE 0ms4028kbC++171.0kb2024-11-16 10:30:422024-11-16 10:30:42

Judging History

你现在查看的是最新测评结果

  • [2024-11-16 10:30:42]
  • 评测
  • 测评结果:RE
  • 用时:0ms
  • 内存:4028kb
  • [2024-11-16 10:30:42]
  • 提交

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

result: