Submission #1081755

# Submission time Handle Problem Language Result Execution time Memory
1081755 2024-08-30T10:07:30 Z vjudge1 Measures (CEOI22_measures) C++17
24 / 100
336 ms 5516 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;
    if(n){
        d*=2;
        vector<int>v(n);
        for(auto &i:v){cin>>i;i*=2;}
        while(m--){
            int x;
            cin>>x;
            x*=2;
            v.push_back(x);
            sort(v.begin(),v.end());
            int l=0,r=1000000000,mid,f;
            r*=r;
            while(l<=r){
                mid=(l+r)/2;
                vector<int>vv=v;
                vv[0]-=mid;
                bool bl=1;
                for(int i=1;i<vv.size();i++){
                    vv[i]=max(vv[i]-mid,vv[i-1]+d);
                    if(abs(vv[i]-v[i])>mid)bl=0;
                }
                if(bl){
                    r=mid-1;
                    f=mid;
                }else l=mid+1;
            }
            cout<<f/2;
            if(f&1)cout<<".5";
            cout<<' ';
        }

    }else{
        d*=2;
        int ls=INT_MIN;
        int ans=0;
        while(m--){
            int x;
            cin>>x;
            x*=2;
            x+=ans;
            int g=d-(x-ls);
            g=max(g,0ll);
            ls=x+g/2;
            ans+=g/2;
            cout<<ans/2;
            if(ans&1)cout<<".5";
            cout<<' ';
        }
    }
}
/*
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:31:30: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   31 |                 for(int i=1;i<vv.size();i++){
      |                             ~^~~~~~~~~~
Main.cpp:41:17: warning: 'f' may be used uninitialized in this function [-Wmaybe-uninitialized]
   41 |             if(f&1)cout<<".5";
      |                ~^~
# Verdict Execution time Memory Grader output
1 Correct 3 ms 344 KB Output is correct
2 Correct 3 ms 524 KB Output is correct
3 Correct 4 ms 344 KB Output is correct
4 Correct 3 ms 528 KB Output is correct
5 Correct 2 ms 348 KB Output is correct
6 Correct 3 ms 348 KB Output is correct
7 Correct 3 ms 348 KB Output is correct
8 Correct 3 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 344 KB Output is correct
2 Correct 3 ms 524 KB Output is correct
3 Correct 4 ms 344 KB Output is correct
4 Correct 3 ms 528 KB Output is correct
5 Correct 2 ms 348 KB Output is correct
6 Correct 3 ms 348 KB Output is correct
7 Correct 3 ms 348 KB Output is correct
8 Correct 3 ms 348 KB Output is correct
9 Correct 308 ms 5468 KB Output is correct
10 Correct 332 ms 5516 KB Output is correct
11 Correct 245 ms 5464 KB Output is correct
12 Correct 336 ms 5500 KB Output is correct
13 Correct 240 ms 4952 KB Output is correct
14 Correct 299 ms 5464 KB Output is correct
15 Correct 283 ms 4696 KB Output is correct
16 Correct 248 ms 5484 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 26 ms 4188 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 26 ms 4188 KB Output isn't correct
2 Halted 0 ms 0 KB -