QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#48938#3962. 100 meter dashMushfiqur05RE 0ms0kbC++2.2kb2022-09-17 15:38:252022-09-17 15:38:27

Judging History

This is the latest submission verdict.

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-09-17 15:38:27]
  • Judged
  • Verdict: RE
  • Time: 0ms
  • Memory: 0kb
  • [2022-09-17 15:38:25]
  • Submitted

answer

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> pi;
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define forn(i, n) for (int i = 1; i <= int(n); i++)
#define sz(v) (int)v.size()

double dis(double x1, double y1, double x2, double y2)
{
    return sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
}

void solve()
{
    ll n; cin >> n;
    double a, b, c;
    a=0.0, b=0.0, c=0.0;
    vector<pair<double, double> > run, prun, srun;
    run.pb(mp(0.0, 0.0));
    prun.pb(mp(0.0, 0.0));
    forn(i, n)
    {
        double x=a, y=b, z=c;
        cin >> a >> b >> c;
        run.pb(mp(dis(x, y, a, b), c-z));
        prun[i].first=prun[i-1].first+run[i].first;
        prun[i].second=prun[i-1].second+run[i].second;
    }
    srun.pb(mp(0.0, 0.0));
    for(int i=n;i>=1;i--)
    {
        double x=srun[n-i].first+run[i].first;
        double y=srun[n-i].second+run[i].second;
        srun.pb(mp(x, y));
    }
    //forn(i, n) cout << srun[i].first << " " << srun[i].second << "\n";
    int ind=1;
    double ans=1e7+7;
    forn(i, n)
    {
        while(prun[ind].first<prun[i-1].first+100.0) { ind++; if(ind>n) break; }
        if(ind>n) break;
        //cout <<  i << " " << ind << " " << prun[ind].first << "\n";
        double rem=(100.0-(prun[ind-1].first-prun[i-1].first));
        ans=min(ans, prun[ind-1].second-prun[i-1].second+
        (rem*(prun[ind].second-prun[ind-1].second))/(prun[ind].first-prun[ind-1].first));
    }
    ind=1;
    forn(i, n)
    {
        while(srun[ind].first<srun[i-1].first+100.0) { ind++; if(ind>n) break; }
        if(ind>n) break;
        //cout <<  i << " " << ind << " " << srun[ind].first << "\n";
        double rem=(100.0-(srun[ind-1].first-srun[i-1].first));
        ans=min(ans, srun[ind-1].second-srun[i-1].second+
        (rem*(srun[ind].second-srun[ind-1].second))/(srun[ind].first-srun[ind-1].first));
    }
    printf("%.15f\n", ans);
}

int main()
{
#ifndef ONLINE_JUDGE
//freopen("input.txt", "r", stdin);
#else
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    int T; T=1; 
    //cin >> T;
    forn(i, T)
    {
        solve();
    }
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Dangerous Syscalls

input:

2
50 0 10
140 0 20

output:


result: