Submission #1005310

# Submission time Handle Problem Language Result Execution time Memory
1005310 2024-06-22T10:13:53 Z ErJ Measures (CEOI22_measures) C++17
59 / 100
504 ms 16296 KB
#include <bits/stdc++.h>

using namespace std;

#define ll long double
#define vi vector<ll>
#define pp pair<ll, ll>
#define vp vector<pp>
#define vvi vector<vi>
#define inf 1000000000000000
#define rep(i,n) for(int i = 0; i < n; i++)

int main(){
    cin.tie(NULL);
    ios_base::sync_with_stdio(false);
    int n, m;
    ll d;
    cin >> n >> m >> d;
    d *= 2;
    if(n != 0){
        vi A(n);
        rep(i, n) {
            cin >> A[i];
            A[i] *= 2;
        }
        ll M = m;
        rep(i, M){
            ll next;
            cin >> next;
            next *= 2;
            A.push_back(next);
            vi B(A.size());
            rep(j, A.size()) B[j] = A[j];
            sort(B.begin(), B.end());
            ll m = B.size();
            vp dp(m);
            dp[0] = {0, B[0]};
            for(int i = 1; i < m; i++){
                ll pos = B[i] + dp[i - 1].first;
                pos = min(pos, max(dp[i - 1].second + d, B[i] - dp[i-1].first));
                ll plus = (dp[i-1].second + d - pos) / 2;
                if(plus < 0) plus = 0;
                dp[i] = {dp[i-1].first + plus, pos + plus};
            }
            long long x = dp[n + i].first;
            cout << x / 2;
            if(x % 2 == 1){
                cout <<".5";
            }
            cout << " ";
        }
    }else{
        vi A(m);
        rep(i,m) {
            cin >> A[i];
            A[i] *= 2;
        }
        vp dp(m);
        dp[0] = {0, A[0]};
        for(int i = 1; i < m; i++){
            ll pos = A[i] + dp[i - 1].first;
            pos = min(pos, max(dp[i - 1].second + d, A[i] - dp[i-1].first));
            ll plus = (dp[i-1].second + d - pos) / 2;
            if(plus < 0) plus = 0;
            dp[i] = {dp[i-1].first + plus, pos + plus};
        }
        rep(i, dp.size()){
            long long x = dp[i].first;
            cout << x / 2;
            if(x %2 == 1){
                cout <<".5";
            }
            cout << " ";
        }
    }
    
    cout << endl;
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:11:35: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long double>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   11 | #define rep(i,n) for(int i = 0; i < n; i++)
......
   33 |             rep(j, A.size()) B[j] = A[j];
      |                 ~~~~~~~~~~~        
Main.cpp:33:13: note: in expansion of macro 'rep'
   33 |             rep(j, A.size()) B[j] = A[j];
      |             ^~~
Main.cpp:11:35: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<long double, long double> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   11 | #define rep(i,n) for(int i = 0; i < n; i++)
......
   67 |         rep(i, dp.size()){
      |             ~~~~~~~~~~~~           
Main.cpp:67:9: note: in expansion of macro 'rep'
   67 |         rep(i, dp.size()){
      |         ^~~
# Verdict Execution time Memory Grader output
1 Correct 3 ms 600 KB Output is correct
2 Correct 2 ms 604 KB Output is correct
3 Correct 2 ms 604 KB Output is correct
4 Correct 3 ms 604 KB Output is correct
5 Correct 2 ms 604 KB Output is correct
6 Correct 2 ms 604 KB Output is correct
7 Correct 3 ms 604 KB Output is correct
8 Correct 2 ms 604 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 600 KB Output is correct
2 Correct 2 ms 604 KB Output is correct
3 Correct 2 ms 604 KB Output is correct
4 Correct 3 ms 604 KB Output is correct
5 Correct 2 ms 604 KB Output is correct
6 Correct 2 ms 604 KB Output is correct
7 Correct 3 ms 604 KB Output is correct
8 Correct 2 ms 604 KB Output is correct
9 Correct 367 ms 16148 KB Output is correct
10 Correct 340 ms 16208 KB Output is correct
11 Correct 215 ms 15528 KB Output is correct
12 Correct 504 ms 15044 KB Output is correct
13 Correct 168 ms 16296 KB Output is correct
14 Correct 265 ms 16296 KB Output is correct
15 Correct 351 ms 14936 KB Output is correct
16 Correct 176 ms 15952 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 54 ms 10836 KB Output is correct
2 Correct 54 ms 12624 KB Output is correct
3 Correct 77 ms 12624 KB Output is correct
4 Correct 48 ms 10580 KB Output is correct
5 Correct 51 ms 11796 KB Output is correct
6 Correct 50 ms 10832 KB Output is correct
7 Correct 52 ms 11800 KB Output is correct
8 Correct 50 ms 10652 KB Output is correct
9 Correct 52 ms 10580 KB Output is correct
10 Correct 63 ms 12880 KB Output is correct
11 Correct 52 ms 11348 KB Output is correct
12 Correct 53 ms 12372 KB Output is correct
13 Correct 47 ms 10616 KB Output is correct
14 Correct 53 ms 12564 KB Output is correct
15 Correct 58 ms 12372 KB Output is correct
16 Correct 57 ms 10516 KB Output is correct
17 Correct 58 ms 11796 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 54 ms 10836 KB Output is correct
2 Correct 54 ms 12624 KB Output is correct
3 Correct 77 ms 12624 KB Output is correct
4 Correct 48 ms 10580 KB Output is correct
5 Correct 51 ms 11796 KB Output is correct
6 Correct 50 ms 10832 KB Output is correct
7 Correct 52 ms 11800 KB Output is correct
8 Correct 50 ms 10652 KB Output is correct
9 Correct 52 ms 10580 KB Output is correct
10 Correct 63 ms 12880 KB Output is correct
11 Correct 52 ms 11348 KB Output is correct
12 Correct 53 ms 12372 KB Output is correct
13 Correct 47 ms 10616 KB Output is correct
14 Correct 53 ms 12564 KB Output is correct
15 Correct 58 ms 12372 KB Output is correct
16 Correct 57 ms 10516 KB Output is correct
17 Correct 58 ms 11796 KB Output is correct
18 Incorrect 52 ms 11876 KB Output isn't correct
19 Halted 0 ms 0 KB -