Submission #683317

#TimeUsernameProblemLanguageResultExecution timeMemory
683317nutellaMeasures (CEOI22_measures)C++17
10 / 100
1543 ms3752 KiB
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int n, m, D;
    cin >> n >> m >> D;

    vector<int> a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }

    vector<int> b(m);
    for (int i = 0; i < m; ++i) {
        cin >> b[i];
    }

    if (n > 0) {
        sort(a.begin(), a.end());

        for (int i = 0; i < m; ++i) {
            a.insert(lower_bound(a.begin(), a.end(), b[i]), b[i]);

            ll ans = numeric_limits<ll>::min();
            for (int k = 0; k < size(a); ++k) {
                ll now = numeric_limits<ll>::min();
                for (int j = k; j < size(a); ++j) {
                    now = max(now, 1LL * D * j - a[j]);
                }
                now -= 1LL * D * k;
                now += a[k];

                ans = max(ans, now);
            }

            if (ans % 2 == 0) {
                cout << ans / 2 << ' ';
            } else {
                cout << ans / 2 << ".5 ";
            }
        }
    } else {
        assert(false);
    }

    return 0;
}

Compilation message (stderr)

Main.cpp: In function 'int main()':
Main.cpp:30:31: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   30 |             for (int k = 0; k < size(a); ++k) {
      |                             ~~^~~~~~~~~
Main.cpp:32:35: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   32 |                 for (int j = k; j < size(a); ++j) {
      |                                 ~~^~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...