Submission #954728

# Submission time Handle Problem Language Result Execution time Memory
954728 2024-03-28T12:42:53 Z LucaIlie Measures (CEOI22_measures) C++17
59 / 100
343 ms 5724 KB
#include <bits/stdc++.h>

using namespace std;

vector<int> v;

int main() {
    int n, q, d;

    cin >> n >> q >> d;

    for ( int i = 0; i < n; i++ ) {
        int p;
        cin >> p;
        v.push_back( p );
    }

    long long minPart = 1e9, ansPart = 0;
    if ( q > 10 ) {
        for ( int i = 0; i < v.size(); i++ ) {
            ansPart = max( ansPart, (long long)d * i - v[i] - minPart );
            minPart = min( minPart, (long long)d * i - v[i] );
        }
    }

    for ( int i = 0; i < q; i++ ) {
        int p;
        cin >> p;

        long long minn = 1e9, ans = 0;
        if ( q > 10 ) {
            ansPart = max( ansPart, (long long)d * (n + i) - p - minPart );
            minPart = min( minPart, (long long)d * (n + i) - p );
            ans = ansPart;
        } else {
            v.push_back( p );
            sort( v.begin(), v.end() );

            for ( int i = 0; i < v.size(); i++ ) {
                ans = max( ans, (long long)d * i - v[i] - minn );
                minn = min( minn, (long long)d * i - v[i] );
            }
        }

        cout << ans / 2;
        if ( ans % 2 == 1 )
            cout << ".5";
        cout << " ";
    }

    return 0;
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:20:28: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   20 |         for ( int i = 0; i < v.size(); i++ ) {
      |                          ~~^~~~~~~~~~
Main.cpp:39:32: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   39 |             for ( int i = 0; i < v.size(); i++ ) {
      |                              ~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 448 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 3 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 2 ms 348 KB Output is correct
7 Correct 2 ms 348 KB Output is correct
8 Correct 2 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 448 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 3 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 2 ms 348 KB Output is correct
7 Correct 2 ms 348 KB Output is correct
8 Correct 2 ms 348 KB Output is correct
9 Correct 140 ms 1496 KB Output is correct
10 Correct 182 ms 1572 KB Output is correct
11 Correct 84 ms 1492 KB Output is correct
12 Correct 194 ms 1496 KB Output is correct
13 Correct 73 ms 1492 KB Output is correct
14 Correct 135 ms 1480 KB Output is correct
15 Correct 117 ms 1420 KB Output is correct
16 Correct 82 ms 1484 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 291 ms 2904 KB Output is correct
2 Correct 307 ms 5340 KB Output is correct
3 Correct 326 ms 5204 KB Output is correct
4 Correct 302 ms 3128 KB Output is correct
5 Correct 298 ms 4176 KB Output is correct
6 Correct 325 ms 3692 KB Output is correct
7 Correct 305 ms 4436 KB Output is correct
8 Correct 298 ms 3004 KB Output is correct
9 Correct 296 ms 3048 KB Output is correct
10 Correct 308 ms 5724 KB Output is correct
11 Correct 299 ms 3920 KB Output is correct
12 Correct 307 ms 4776 KB Output is correct
13 Correct 333 ms 2896 KB Output is correct
14 Correct 313 ms 4904 KB Output is correct
15 Correct 343 ms 4760 KB Output is correct
16 Correct 287 ms 2640 KB Output is correct
17 Correct 303 ms 4268 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 291 ms 2904 KB Output is correct
2 Correct 307 ms 5340 KB Output is correct
3 Correct 326 ms 5204 KB Output is correct
4 Correct 302 ms 3128 KB Output is correct
5 Correct 298 ms 4176 KB Output is correct
6 Correct 325 ms 3692 KB Output is correct
7 Correct 305 ms 4436 KB Output is correct
8 Correct 298 ms 3004 KB Output is correct
9 Correct 296 ms 3048 KB Output is correct
10 Correct 308 ms 5724 KB Output is correct
11 Correct 299 ms 3920 KB Output is correct
12 Correct 307 ms 4776 KB Output is correct
13 Correct 333 ms 2896 KB Output is correct
14 Correct 313 ms 4904 KB Output is correct
15 Correct 343 ms 4760 KB Output is correct
16 Correct 287 ms 2640 KB Output is correct
17 Correct 303 ms 4268 KB Output is correct
18 Incorrect 305 ms 4352 KB Output isn't correct
19 Halted 0 ms 0 KB -