QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#113177#5505. Great ChaselftroqWA 2ms5756kbC++142.3kb2023-06-16 16:40:052023-06-16 16:40:06

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-06-16 16:40:06]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:5756kb
  • [2023-06-16 16:40:05]
  • 提交

answer

/*
                     ,
                ,.  | \
               |: \ ; :\
               :' ;\| ::\
                \ : | `::\
                _)  |   `:`.
              ,' , `.    ;: ;
            ,' ;:  ;"'  ,:: |_
           /,   ` .    ;::: |:`-.__
        _,' _o\  ,::.`:' ;  ;   . '
    _,-'           `:.          ;""\,
 ,-'                     ,:         `-;,
 \,                       ;:           ;--._
  `.______,-,----._     ,' ;:        ,/ ,  ,`
         / /,-';'  \     ; `:      ,'/,::.:::
       ,',;-'-'_,--;    ;   :.   ,',',;::::::
      ( /___,-'     `.     ;::,,'o/  ,:::::::
       `'             )    ;:,'o /  ;"-   -::
                      \__ _,'o ,'         ,::
                         ) `--'       ,..::::
      _lftroq_           ; `.        ,:::::::
                          ;  ``::.    :::::::
*/
#include <bits/stdc++.h>
#define fastIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define MOD 1000000007LL
#define MOD2 998244353LL
#define endl '\n'
#define INFINITE 2147483647LL
#define INFINITE2 9223372036854775807
#define llll pair<ll,ll>
#define fi first
#define se second
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

using namespace std;

ll n,v;
ll a[400005],b[400005];
ld l,r,ma,mi;

bool check(ld k)
{
    //cout << k << ": ";
    ld x=-INFINITE2,y=INFINITE2;
    for(int i=1;i<=n;i++)
    {
        if(a[i]<=0) x=max(x,a[i]+k*b[i]);
        else y=min(y,a[i]-k*b[i]);
    }
    //cout << x << " " << y << endl;
    if(x>=y) return false;
    return true;
}

void solve()
{
    ld ans=0;
    l=r=ma=mi=0;
    cin >> n >> v;
    for(int i=1;i<=n;i++)
    {
        cin >> a[i] >> b[i];
        ma=max(ma,(ld)a[i]);
        mi=min(mi,(ld)a[i]);
    }
    l=0,r=ma-mi;
    ll temp=0;
    while(l<=r&&temp<=30000)
    {
        ld mid=(l+r)/2.0;
        if(check(mid))
        {
            ans=mid;
            l=mid+0.00000001;
        }
        else r=mid-0.00000001;
        temp++;
    }
    cout << setprecision(15) << fixed << ans*v << endl;
}

int main()
{
    fastIO
    //freopen("hanhhhh.inp","r",stdin);
    //freopen("hanhhhh.out","w",stdout);
    ll t=1;
    cin >> t;
    while(t--)
    solve();
    return 0;
}

详细

Test #1:

score: 0
Wrong Answer
time: 2ms
memory: 5756kb

input:

3
4 9
10 2
-7 2
-6 1
7 1
2 8
-1 7
1 6
2 3
-1000000000000 1
1000000000000 1

output:

38.249999955000000
1.230769208926650
2999999999999.999999761581421

result:

wrong answer 2nd numbers differ - expected: '1.2307692', found: '1.2307692', error = '0.0000000'