求助!!!最后一个WA!!!!
查看原帖
求助!!!最后一个WA!!!!
1142264
andy22楼主2024/12/15 17:19
#include <bits/stdc++.h>
using namespace std;

const int N = 1e2 + 5;
double d[N], p[N];
double d1, c, d2;
int n;
int main(){
    cin >> d1 >> c >> d2 >> p[0] >> n;

    double s = c*d2, ans = 0, y = 0;
    cout << s << endl;
    for(int i = 1; i <= n; i++) {
        cin >> d[i] >> p[i];
        if(d[i] - d[i-1] > s) {
            cout << "No Solution";
            return 0;
        }
    }
    d[n+1] = d1;
    p[n+1] = 5001;//?
    int q = 0;
    while(q <= n) {//?
        int last = q, max;
        for(int i = q+1; i <= n+1 && d[i] - d[q] <= s; i++) {
            max = i;
            if(p[i] < p[last]) {
                last = i;
                break;
            }
        }
        if(last == q) {
            cout << "1 " << q << " " << c * p[q] << endl;
            ans += c * p[q];
            q = max;
        } else {
            cout << "2 " <<  q << " " << (d[last] - d[q]) / d2 * p[q] << endl;
            ans += (d[last] - d[q]) / d2 * p[q];
            q = last;
        }
        cout << q << endl;
    }
    cout << fixed << setprecision(2) << ans;
    return 0;
}
2024/12/15 17:19
加载中...