Submission #1102665

# Submission time Handle Problem Language Result Execution time Memory
1102665 2024-10-18T15:18:17 Z vladilius Measures (CEOI22_measures) C++17
59 / 100
160 ms 5452 KB
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define pb push_back
#define ff first
#define ss second

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    
    cout<<fixed<<setprecision(15);
    auto print = [&](ll x){
        if (x % 2 == 0){
            cout<<x / 2<<" ";
        }
        else {
            cout<<(x - 1) / 2<<".5 ";
        }
    };
    
    int n, m, d; cin>>n>>m>>d;
    vector<int> a;
    for (int i = 1; i <= n; i++){
        int x; cin>>x;
        a.pb(x);
    }
    
    if (m <= 10){
        while (m--){
            int x; cin>>x;
            a.pb(x);
            sort(a.begin(), a.end());
            
            vector<ll> f(a.size());
            f[0] = a[0];
            for (int i = 1; i < a.size(); i++){
                f[i] = max((ll) a[i], f[i - 1] + d);
            }
            
            ll out = 0;
            for (int i = 0; i < f.size(); i++){
                out = max(out, f[i] - a[i]);
            }
            print(out);
        }
        return 0;
    }
    
    ll p = -d, out = 0;
    for (int i = 0; i < m; i++){
        int x; cin>>x;
        p = max((ll) x, p + d);
        out = max(out, p - x);
        
        print(out);
    }
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:39:31: 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 = 1; i < a.size(); i++){
      |                             ~~^~~~~~~~~~
Main.cpp:44:31: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   44 |             for (int i = 0; i < f.size(); i++){
      |                             ~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 504 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 2 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 2 ms 508 KB Output is correct
7 Correct 2 ms 472 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 504 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 2 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 2 ms 508 KB Output is correct
7 Correct 2 ms 472 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 95 ms 4816 KB Output is correct
10 Correct 142 ms 4844 KB Output is correct
11 Correct 43 ms 4864 KB Output is correct
12 Correct 160 ms 4808 KB Output is correct
13 Correct 44 ms 4304 KB Output is correct
14 Correct 90 ms 4816 KB Output is correct
15 Correct 91 ms 4048 KB Output is correct
16 Correct 48 ms 4708 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 23 ms 1360 KB Output is correct
2 Correct 33 ms 3400 KB Output is correct
3 Correct 28 ms 5196 KB Output is correct
4 Correct 24 ms 3156 KB Output is correct
5 Correct 28 ms 4436 KB Output is correct
6 Correct 26 ms 3412 KB Output is correct
7 Correct 39 ms 4428 KB Output is correct
8 Correct 25 ms 3148 KB Output is correct
9 Correct 25 ms 3156 KB Output is correct
10 Correct 32 ms 5452 KB Output is correct
11 Correct 27 ms 3916 KB Output is correct
12 Correct 30 ms 4948 KB Output is correct
13 Correct 24 ms 3156 KB Output is correct
14 Correct 31 ms 5080 KB Output is correct
15 Correct 29 ms 4948 KB Output is correct
16 Correct 22 ms 2644 KB Output is correct
17 Correct 28 ms 4436 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 23 ms 1360 KB Output is correct
2 Correct 33 ms 3400 KB Output is correct
3 Correct 28 ms 5196 KB Output is correct
4 Correct 24 ms 3156 KB Output is correct
5 Correct 28 ms 4436 KB Output is correct
6 Correct 26 ms 3412 KB Output is correct
7 Correct 39 ms 4428 KB Output is correct
8 Correct 25 ms 3148 KB Output is correct
9 Correct 25 ms 3156 KB Output is correct
10 Correct 32 ms 5452 KB Output is correct
11 Correct 27 ms 3916 KB Output is correct
12 Correct 30 ms 4948 KB Output is correct
13 Correct 24 ms 3156 KB Output is correct
14 Correct 31 ms 5080 KB Output is correct
15 Correct 29 ms 4948 KB Output is correct
16 Correct 22 ms 2644 KB Output is correct
17 Correct 28 ms 4436 KB Output is correct
18 Incorrect 35 ms 4428 KB Output isn't correct
19 Halted 0 ms 0 KB -