답안 #862911

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
862911 2023-10-19T11:12:59 Z Trisanu_Das Measures (CEOI22_measures) C++17
59 / 100
184 ms 7792 KB
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
#define pb       push_back
#define mp       make_pair
#define all(x)   x.begin(), x.end()
#define ff       first
#define ss       second
 
ll d, a[500005];
 
ll solve(int n){
    sort(a, a + n);
    ll lastpos = a[0], tim = 0;
    for(int i = 1; i < n; i++){
        if(a[i] - lastpos >= d) lastpos = max(lastpos + d, a[i] - tim);
        else if(a[i] + tim - lastpos >= d) lastpos += d;
        else{
            ll need = d - (a[i] - lastpos) - tim, x = a[i] + tim;
            need /= 2;
            tim += need;
            lastpos = x + need;
        }
    }
    return tim;
}
 
 
int main(){
    ios_base::sync_with_stdio(false); cin.tie(0);
    int n, m; cin >> n >> m >> d;
    d *= 2;
    for(int i = 0; i < n; i++){
        cin >> a[i];
        a[i] *= 2;
    }
    sort(a, a + n);
    ll lastpos, tim;
    for(int i = 0; i < m; i++){
        cin >> a[i + n];
        a[i + n] *= 2;
        ll ans;
        if(m > 10){
            if(i == 0) lastpos = a[0], tim = 0;
            else{
                if(a[i] - lastpos >= d) lastpos = max(lastpos + d, a[i] - tim);
                else if(a[i] + tim - lastpos >= d) lastpos += d;
                else{
                    ll need = d - (a[i] - lastpos) - tim, x = a[i] + tim;
                    need /= 2;
                    tim += need;
                    lastpos = x + need;
                }
            }
            ans = tim;
        }
        else ans = solve(i + n + 1);
        cout << ans / 2 << (ans & 1 ? ".5 " : " ");
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 376 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 2 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 376 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 2 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 115 ms 2648 KB Output is correct
10 Correct 170 ms 2924 KB Output is correct
11 Correct 36 ms 2648 KB Output is correct
12 Correct 184 ms 2668 KB Output is correct
13 Correct 49 ms 2648 KB Output is correct
14 Correct 111 ms 2648 KB Output is correct
15 Correct 100 ms 2652 KB Output is correct
16 Correct 53 ms 2652 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 32 ms 5204 KB Output is correct
2 Correct 35 ms 7516 KB Output is correct
3 Correct 34 ms 7508 KB Output is correct
4 Correct 30 ms 5332 KB Output is correct
5 Correct 33 ms 6484 KB Output is correct
6 Correct 33 ms 5716 KB Output is correct
7 Correct 32 ms 6736 KB Output is correct
8 Correct 29 ms 5460 KB Output is correct
9 Correct 29 ms 5212 KB Output is correct
10 Correct 42 ms 7792 KB Output is correct
11 Correct 31 ms 5972 KB Output is correct
12 Correct 33 ms 6992 KB Output is correct
13 Correct 34 ms 5204 KB Output is correct
14 Correct 42 ms 7252 KB Output is correct
15 Correct 34 ms 6992 KB Output is correct
16 Correct 34 ms 4948 KB Output is correct
17 Correct 36 ms 6480 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 32 ms 5204 KB Output is correct
2 Correct 35 ms 7516 KB Output is correct
3 Correct 34 ms 7508 KB Output is correct
4 Correct 30 ms 5332 KB Output is correct
5 Correct 33 ms 6484 KB Output is correct
6 Correct 33 ms 5716 KB Output is correct
7 Correct 32 ms 6736 KB Output is correct
8 Correct 29 ms 5460 KB Output is correct
9 Correct 29 ms 5212 KB Output is correct
10 Correct 42 ms 7792 KB Output is correct
11 Correct 31 ms 5972 KB Output is correct
12 Correct 33 ms 6992 KB Output is correct
13 Correct 34 ms 5204 KB Output is correct
14 Correct 42 ms 7252 KB Output is correct
15 Correct 34 ms 6992 KB Output is correct
16 Correct 34 ms 4948 KB Output is correct
17 Correct 36 ms 6480 KB Output is correct
18 Incorrect 34 ms 6736 KB Output isn't correct
19 Halted 0 ms 0 KB -