QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#528030#2528. Mobile RobotTahmid76WA 10ms13264kbC++142.5kb2024-08-23 04:17:222024-08-23 04:17:23

Judging History

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

  • [2024-08-23 04:17:23]
  • 评测
  • 测评结果:WA
  • 用时:10ms
  • 内存:13264kb
  • [2024-08-23 04:17:22]
  • 提交

answer

//And He found you lost and guided [you] [93:07]

//#pragma GCC optimize ("Ofast")
//#pragma GCC target ("avx2")
//#pragma GCC optimize("unroll-loops")

#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef vector<ll> vll;
typedef vector<int> vii;
typedef map<int,int> mpi;
typedef map<ll,ll> mpl;
typedef unordered_map<int,int> umpi;
typedef unordered_map<ll,ll> umpl;

#define modu 998244353 
#define mod 1000000007
#define eps 1e-7
#define inf 1000000000000000006
#define ff first
#define ss second
#define pb push_back
#define all(v) v.begin(), v.end()
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define endl '\n'
#define pi acos(-1.0)
#define dec(n) fixed << setprecision(n)
#define N 300005
#define int __int128

int n,d,a[N];
int c[N];
int f(int sft){
    
    c[1]=a[1];
    int f1=1,del1=0;
    c[1]-=sft;
    for(int i=2;i<=n;i++){
        c[i]=c[i-1]+d;
        if(c[i]>a[i]+sft) f1=0;
        int gap=max((int)0,a[i]-sft-c[i]);
        c[i]=c[i]+gap;
        del1+=gap; 
        // cout << gap << " ";

    }
    if(del1>2*sft) f1=0;
    c[1]=a[1];
    c[1]-=sft;
    for(int i=2;i<=n;i++) c[i]=c[i-1]+d;
    for(int i=1;i<=n;i++){
        if(del1+c[i]>a[i]+sft) f1=0;
    }

    c[1]=a[1];
    int f2=1,del2=0;
    c[1]+=sft;
    for(int i=2;i<=n;i++){
        c[i]=c[i-1]-d;
        if(c[i]<a[i]-sft) f2=0;
        int gap=max((int)0,c[i]-a[i]-sft);
        c[i]=c[i]-gap;
        del2+=gap; 

    }
    c[1]=a[1];
    c[1]+=sft;
    for(int i=2;i<=n;i++) c[i]=c[i-1]-d;

    for(int i=1;i<=n;i++){
        if(c[i]-del2<a[i]-sft) f2=0;
    }

    if(del2>2*sft) f2=0;


    return (f1 || f2);

}


long long NN,D,A[N];

void solve(){
    cin >> NN >> D;
    n=NN;
    d=D;
    for(int i=1;i<=n;i++){
        cin >> A[i];
        a[i]=A[i]*2LL;
    } 

    d*=2;


    int lo=0,hi=1e25+1,ans;
    while(lo<=hi){
        int mid=(lo+hi)/2;
        if(f(mid)){
            ans=mid;
            hi=mid-1;
        }
        else lo=mid+1;
    }



    cout << (long long)ans/2LL << ".";
    if(ans%2) cout << 5 << endl;
    else cout << 0 << endl;

    
}


signed main(){
    fastio;
    //srand(chrono::steady_clqk::now().time_since_epqh().count());
    // fflush(stdout);
    int T=1,cs=0;
    // cin >> T;
    while(T--){
        //cout << "Case " << ++cs << ": " ; 
        solve();
    } 
    return 0;
}

详细

Test #1:

score: 100
Accepted
time: 1ms
memory: 7808kb

input:

2 1
-1 1

output:

0.5

result:

ok single line: '0.5'

Test #2:

score: 0
Accepted
time: 1ms
memory: 7768kb

input:

2 1
0 1

output:

0.0

result:

ok single line: '0.0'

Test #3:

score: 0
Accepted
time: 1ms
memory: 7748kb

input:

2 1
0 0

output:

0.5

result:

ok single line: '0.5'

Test #4:

score: 0
Accepted
time: 1ms
memory: 7752kb

input:

2 1
-10000000000000000 10000000000000000

output:

9999999999999999.5

result:

ok single line: '9999999999999999.5'

Test #5:

score: 0
Accepted
time: 1ms
memory: 7768kb

input:

2 10000000000
0 0

output:

5000000000.0

result:

ok single line: '5000000000.0'

Test #6:

score: 0
Accepted
time: 1ms
memory: 7696kb

input:

2 10000000000
-10000000000000000 10000000000000000

output:

9999995000000000.0

result:

ok single line: '9999995000000000.0'

Test #7:

score: 0
Accepted
time: 1ms
memory: 7764kb

input:

10 1
0 1 2 3 4 5 6 7 8 9

output:

0.0

result:

ok single line: '0.0'

Test #8:

score: 0
Accepted
time: 1ms
memory: 7740kb

input:

10 1
9 8 7 6 5 4 3 2 1 0

output:

0.0

result:

ok single line: '0.0'

Test #9:

score: 0
Accepted
time: 1ms
memory: 7720kb

input:

10 3
0 1 2 3 4 5 6 7 8 9

output:

9.0

result:

ok single line: '9.0'

Test #10:

score: 0
Accepted
time: 1ms
memory: 7700kb

input:

5 1
1 3 5 7 9

output:

2.0

result:

ok single line: '2.0'

Test #11:

score: 0
Accepted
time: 1ms
memory: 7768kb

input:

10 3
9 8 7 6 5 4 3 2 1 0

output:

9.0

result:

ok single line: '9.0'

Test #12:

score: 0
Accepted
time: 1ms
memory: 7820kb

input:

3 1
1 3 2

output:

1.0

result:

ok single line: '1.0'

Test #13:

score: 0
Accepted
time: 1ms
memory: 7776kb

input:

6 1
3 1 2 5 6 4

output:

2.0

result:

ok single line: '2.0'

Test #14:

score: 0
Accepted
time: 1ms
memory: 7752kb

input:

6 1
4 6 5 2 1 3

output:

2.0

result:

ok single line: '2.0'

Test #15:

score: 0
Accepted
time: 1ms
memory: 7804kb

input:

10 1
6 7 8 9 10 1 2 3 4 5

output:

4.0

result:

ok single line: '4.0'

Test #16:

score: 0
Accepted
time: 1ms
memory: 7684kb

input:

10 10
6 7 8 9 10 1 2 3 4 5

output:

44.5

result:

ok single line: '44.5'

Test #17:

score: 0
Accepted
time: 1ms
memory: 7716kb

input:

6 2
6 3 5 2 4 1

output:

3.5

result:

ok single line: '3.5'

Test #18:

score: 0
Accepted
time: 1ms
memory: 7752kb

input:

10 10000000000
60000000000 70000000000 80000000000 90000000000 100000000000 10000000000 20000000000 30000000000 40000000000 50000000000

output:

40000000000.0

result:

ok single line: '40000000000.0'

Test #19:

score: 0
Accepted
time: 1ms
memory: 7776kb

input:

10 10000000000
6000000000 7000000000 8000000000 9000000000 10000000000 1000000000 2000000000 3000000000 4000000000 5000000000

output:

44500000000.0

result:

ok single line: '44500000000.0'

Test #20:

score: -100
Wrong Answer
time: 10ms
memory: 13264kb

input:

1000000 10000000000
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...

output:

0.0

result:

wrong answer 1st lines differ - expected: '4999995000000000.0', found: '0.0'