Submission #1081660

# Submission time Handle Problem Language Result Execution time Memory
1081660 2024-08-30T08:52:50 Z vjudge1 Measures (CEOI22_measures) C++17
0 / 100
38 ms 10712 KB
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define mod 998244353
#define int long long
#define endl '\n'
using namespace std;
using namespace __gnu_pbds;
using ordered_set = tree<pair<pair<int,int>,int>,null_type,less<pair<pair<int,int>,int>>,rb_tree_tag,tree_order_statistics_node_update>;
signed main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int n,m,d;
    cin>>n>>m>>d;
    d*=2;
    if(!n){
        deque<pair<int,int>>a,b;
        int tt=0,l=0,r=0,ans=0;
        while(m--){
            int x;
            cin>>x;
            x*=2;
            ans+=(a.size()?max(0ll,d-(x-a.back().first)):0);
            a.push_back({x,(a.size()?max(0ll,d-(x-a.back().first))+a.back().second:0)});
            if(b.size())tt+=max(0ll,d-(x-b.back().first));
            b.push_back({x,-tt});
            // cout<<ans<<' ';
            while(r+1<a.size()||l<r){
                if(l<r){
                    int k=max(a.back().second-a[r].second,(b[0].second+tt)-(b[r].second+tt));
                    // cout<<r<<' '<<b[0].second-b[r].second<<' ';
                    if(k<=ans){
                        ans=k;
                        l++;
                    }else break;
                }else{
                    int k=max(a.back().second-a[r+1].second,(b[0].second+tt)-(b[r].second+tt))+max(0ll,d-(a[r+1].first-a[r].first))/2;
                    if(k<=ans){
                        ans=k;
                        r++;
                    }else break;
                }
            }
            cout<<ans/2;
            if(ans&1)cout<<".5";
            cout<<' ';
        }
    }else{

    }
}
/*
1
13
7 10 13 |4 |5 10| 8| 3 6 5 |7 10| 2


*/

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:27:22: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::deque<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   27 |             while(r+1<a.size()||l<r){
      |                   ~~~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 38 ms 10712 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 38 ms 10712 KB Output isn't correct
2 Halted 0 ms 0 KB -