CSES - Aalto Competitive Programming 2024 - wk1 - Wed - Results
Submission details
Task:Aquarium
Sender:aalto2024a_001
Submission time:2024-09-04 16:49:03 +0300
Language:C++ (C++17)
Status:READY
Result:ACCEPTED
Test results
testverdicttime
#1ACCEPTED0.00 sdetails
#2ACCEPTED0.00 sdetails
#3ACCEPTED0.00 sdetails
#4ACCEPTED0.00 sdetails
#5ACCEPTED0.00 sdetails
#6ACCEPTED0.00 sdetails
#7ACCEPTED0.00 sdetails
#8ACCEPTED0.00 sdetails
#9ACCEPTED0.00 sdetails
#10ACCEPTED0.00 sdetails
#11ACCEPTED0.00 sdetails
#12ACCEPTED0.00 sdetails
#13ACCEPTED0.00 sdetails
#14ACCEPTED0.00 sdetails
#15ACCEPTED0.00 sdetails
#16ACCEPTED0.00 sdetails
#17ACCEPTED0.00 sdetails
#18ACCEPTED0.00 sdetails
#19ACCEPTED0.00 sdetails
#20ACCEPTED0.00 sdetails
#21ACCEPTED0.00 sdetails
#22ACCEPTED0.00 sdetails
#23ACCEPTED0.00 sdetails
#24ACCEPTED0.00 sdetails
#25ACCEPTED0.00 sdetails
#26ACCEPTED0.00 sdetails
#27ACCEPTED0.00 sdetails
#28ACCEPTED0.00 sdetails
#29ACCEPTED0.00 sdetails
#30ACCEPTED0.00 sdetails
#31ACCEPTED0.00 sdetails
#32ACCEPTED0.00 sdetails
#33ACCEPTED0.00 sdetails
#34ACCEPTED0.00 sdetails
#35ACCEPTED0.00 sdetails
#36ACCEPTED0.00 sdetails
#37ACCEPTED0.00 sdetails
#38ACCEPTED0.00 sdetails
#39ACCEPTED0.00 sdetails
#40ACCEPTED0.00 sdetails
#41ACCEPTED0.00 sdetails
#42ACCEPTED0.00 sdetails
#43ACCEPTED0.00 sdetails
#44ACCEPTED0.00 sdetails

Code

#ifdef ONPC
    #define _GLIBCXX_DEBUG
#endif
#include <bits/stdc++.h>

#define char unsigned char
#define rep(i, a, b) for(int i=a; i< (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back

#define LSOne(S) ((S) & -(S))

using namespace std;
// mt19937 rnd(239);
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

typedef long long C;
typedef complex<C> P;
#define X real()
#define Y imag()

template<class T>
istream& operator>> (istream& is, complex<T>& p) {
    T value;
    is >> value;
    p.real(value);
    is >> value;
    p.imag(value);
    return is;
}

typedef long long ll;
typedef long double ld;

using pi = pair<ll, ll>;
using vi = vector<ll>;
template <class T>
using pq = priority_queue<T>;
template <class T>
using pqg = priority_queue<T, vector<T>, greater<T>>;

int popcnt(int x) { return __builtin_popcount(x); }
int popcnt(ll x) { return __builtin_popcountll(x); }

#define MIN(v) *min_element(all(v))
#define MAX(v) *max_element(all(v))
#define LB(c, x) distance((c).begin(), lower_bound(all(c), (x)))
#define UB(c, x) distance((c).begin(), upper_bound(all(c), (x)))

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ", "; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? ", " : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifdef DEBUG
#define dbg(x...) cerr << "\e[91m"<<__func__<<":"<<__LINE__<<" [" << #x << "] = ["; _print(x); cerr << "\e[39m" << endl;
#else
#define dbg(x...)
#endif

template<typename S, typename T = S> void chmin(S &s, T t) {s = s < t ? s : t;}
template<typename S, typename T = S> void chmax(S &s, T t) {s = s > t ? s : t;}

const int INF = 1e9; // 10^9 = 1B is < 2^31-1
const ll LLINF = 4e18; // 4*10^18 is < 2^63-1
const double EPS = 1e-4;
const ll MOD = 1e9+7;

const int N=1e4+10;
long double v[N];
int n;
ll q, V;

bool ok(float target) {
    int left=q, right=q;
    while(left>=1 && v[left]<target) left--;
    while(right<=n && v[right]<target) {
        right++;
    }


    if(left==0 || right==n+1) return false;

    long double need=(right-left-1)*target;
    
    return need<=V;
}

int solve() {
    std::cin >> n;
    for (int i = 1; i <= n; i++) {
        std::cin >> v[i];
    }
    std::cout << fixed << setprecision(8);

    std::cin >> q >> V;



    long double lo=0.0, hi=1e12;

    while(hi-lo>0.0001) {
        long double mid=(lo+hi)/2;
        if(ok(mid)) {
            lo=mid;
        } else {
            hi=mid;
        }
    }
    //std::cout << lo << " " << hi << std::endl;

    std::cout << hi << std::endl;


    return 0;
}

int32_t main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int TET = 1;
    //cin >> TET;
    for (int i = 1; i <= TET; i++) {
        #ifdef ONPC
            cout << "TEST CASE#" << i << endl;
        #endif
        
        if (solve()) {
            break;
        }

        #ifdef ONPC
            cout << "__________________________" << endl;
        #endif
    }
    #ifdef ONPC
        cerr << endl << "finished in " << clock() * 1.0 / CLOCKS_PER_SEC << " sec" << endl;
    #endif
}

Test details

Test 1

Verdict: ACCEPTED

input
1

1 1

correct output
1

user output
1.00003339

Test 2

Verdict: ACCEPTED

input
2
1 2 
1 1

correct output
1

user output
1.00003339

Test 3

Verdict: ACCEPTED

input
3
1 1 3 
2 7

correct output
1

user output
1.00003339

Test 4

Verdict: ACCEPTED

input
5
1 1 5 3 5 
3 6

correct output
5

user output
5.00000041

Test 5

Verdict: ACCEPTED

input
6
5 3 1 2 4 6 
3 4

correct output
2

user output
2.00001127

Test 6

Verdict: ACCEPTED

input
8
7 5 3 1 2 4 6 8 
4 7

correct output
3

user output
3.00004466

Test 7

Verdict: ACCEPTED

input
9
2 1 9 5 9 4 5 4 3 
4 5

correct output
5

user output
5.00000041

Test 8

Verdict: ACCEPTED

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

correct output
3.66667

user output
3.66667807

Test 9

Verdict: ACCEPTED

input
12
11 9 7 5 3 1 2 4 6 8 10 12 
6 16

correct output
4

user output
4.00002254

Test 10

Verdict: ACCEPTED

input
14
13 11 9 7 5 3 1 2 4 6 8 10 12 ...

correct output
5

user output
5.00000041

Test 11

Verdict: ACCEPTED

input
16
15 13 11 9 7 5 3 1 2 4 6 8 10 ...

correct output
5.6

user output
5.60002045

Test 12

Verdict: ACCEPTED

input
18
17 15 13 11 9 7 5 3 1 2 4 6 8 ...

correct output
6

user output
6.00003380

Test 13

Verdict: ACCEPTED

input
20
19 17 15 13 11 9 7 5 3 1 2 4 6...

correct output
7

user output
7.00001168

Test 14

Verdict: ACCEPTED

input
25
5 1 24 14 24 11 13 11 9 9 4 6 ...

correct output
6

user output
6.00003380

Test 15

Verdict: ACCEPTED

input
30
29 27 25 23 21 19 17 15 13 11 ...

correct output
10

user output
10.00000083

Test 16

Verdict: ACCEPTED

input
40
39 37 35 33 31 29 27 25 23 21 ...

correct output
13.4615

user output
13.46156520

Test 17

Verdict: ACCEPTED

input
50
49 47 45 43 41 39 37 35 33 31 ...

correct output
17

user output
17.00001251

Test 18

Verdict: ACCEPTED

input
70
69 67 65 63 61 59 57 55 53 51 ...

correct output
23.2609

user output
23.26089321

Test 19

Verdict: ACCEPTED

input
1

1 1

correct output
1

user output
1.00003339

Test 20

Verdict: ACCEPTED

input
2
3 2 
1 16

correct output
3

user output
3.00004466

Test 21

Verdict: ACCEPTED

input
3
6 4 3 
3 81

correct output
3

user output
3.00004466

Test 22

Verdict: ACCEPTED

input
5
14 8 5 24 16 
5 625

correct output
16

user output
16.00003463

Test 23

Verdict: ACCEPTED

input
6
19 11 6 34 23 35 
3 1296

correct output
19

user output
19.00002378

Test 24

Verdict: ACCEPTED

input
8
32 18 9 61 39 62 32 35 
4 4096

correct output
61

user output
61.00003835

Test 25

Verdict: ACCEPTED

input
9
40 22 10 77 49 78 40 44 39 
3 6561

correct output
40

user output
40.00000331

Test 26

Verdict: ACCEPTED

input
10
49 26 12 94 60 96 49 54 48 39 
4 10000

correct output
94

user output
94.00002998

Test 27

Verdict: ACCEPTED

input
12
69 36 15 135 85 138 69 76 67 5...

correct output
69

user output
69.00002791

Test 28

Verdict: ACCEPTED

input
14
93 47 18 184 114 187 93 102 90...

correct output
141

user output
141.00004497

Test 29

Verdict: ACCEPTED

input
16
121 60 22 240 148 244 120 132 ...

correct output
240

user output
240.00001986

Test 30

Verdict: ACCEPTED

input
18
151 74 25 303 186 308 151 166 ...

correct output
303

user output
303.00006948

Test 31

Verdict: ACCEPTED

input
20
186 90 29 374 229 381 185 204 ...

correct output
286

user output
286.00005697

Test 32

Verdict: ACCEPTED

input
25
287 136 40 584 355 594 286 316...

correct output
516

user output
516.00007600

Test 33

Verdict: ACCEPTED

input
30
409 191 52 841 508 855 409 452...

correct output
656

user output
656.00003207

Test 34

Verdict: ACCEPTED

input
40
720 328 80 1494 898 1519 719 7...

correct output
1519

user output
1519.00009238

Test 35

Verdict: ACCEPTED

input
50
1118 503 113 2333 1397 2372 11...

correct output
2372

user output
2372.00015185

Test 36

Verdict: ACCEPTED

input
70
2176 964 195 4570 2725 4648 21...

correct output
4648

user output
4648.00026245

Test 37

Verdict: ACCEPTED

input
100
4416 1932 356 9323 5542 9483 4...

correct output
9700

user output
9700.00052503

Test 38

Verdict: ACCEPTED

input
500
104548 249301 180224 233177 52...

correct output
104548

user output
104548.00392079

Test 39

Verdict: ACCEPTED

input
600
150482 358999 259492 335771 64...

correct output
353835

user output
353835.01567621

Test 40

Verdict: ACCEPTED

input
900
446578 58127 573897 680544 236...

correct output
790626

user output
790626.03125513

Test 41

Verdict: ACCEPTED

input
900
783372 729637 443692 140636 78...

correct output
805592

user output
805592.03130548

Test 42

Verdict: ACCEPTED

input
100
4416 1932 356 9323 5542 9483 4...

correct output
9700

user output
9700.00052503

Test 43

Verdict: ACCEPTED

input
500
104548 249301 180224 233177 52...

correct output
104548

user output
104548.00392079

Test 44

Verdict: ACCEPTED

input
600
150482 358999 259492 335771 64...

correct output
353835

user output
353835.01567621