Submission #691533

# Submission time Handle Problem Language Result Execution time Memory
691533 2023-01-31T08:37:13 Z fatemetmhr Measures (CEOI22_measures) C++17
35 / 100
46 ms 6968 KB
// hmmm... na dige chizi baraye goftan namoonde
 
 
// ~ Be Name Khoda ~

#include <bits/stdc++.h>
//#pragma GCC optimize ("Ofast")
//#pragma GCC target("avx2")
//#pragma GCC optimize("unroll-loops,O3")

using namespace std;

typedef long long ll;

#define pb       push_back
#define mp       make_pair
#define all(x)   x.begin(), x.end()
#define fi       first
#define se       second

const int maxn  =  1e6   + 10;
const int maxn5 =  5e5   + 10;
const int maxnt =  1.2e6 + 10;
const int maxn3 =  1e3   + 10;
const int mod   =  1e9   +  7;
const ll  inf   =  1e18;

ll d;
ll a[maxn5];

inline ll solve(int n){
    cout << "ok " << n << endl;
    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;
            ll x = a[i] + tim;
            //cout << "here " << x << ' ' << need << ' ' << tim << endl;
            need /= 2;
            tim += need;
            lastpos = x + need;
        }
        cout << i << ' ' << lastpos << ' ' << tim << endl;
    }
    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;
                    ll x = a[i] + tim;
                    //cout << "here " << x << ' ' << need << ' ' << tim << endl;
                    need /= 2;
                    tim += need;
                    lastpos = x + need;
                }
            }
            ans = tim;
        }
        else
            ans = solve(i + n + 1);
        cout << ans / 2 << (ans & 1 ? ".5 " : " ");
    }
    cout << endl;

}
# Verdict Execution time Memory Grader output
1 Incorrect 27 ms 720 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 27 ms 720 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 39 ms 3784 KB Output is correct
2 Correct 46 ms 6780 KB Output is correct
3 Correct 39 ms 6684 KB Output is correct
4 Correct 38 ms 4572 KB Output is correct
5 Correct 40 ms 5868 KB Output is correct
6 Correct 37 ms 4940 KB Output is correct
7 Correct 44 ms 5932 KB Output is correct
8 Correct 33 ms 4600 KB Output is correct
9 Correct 35 ms 4556 KB Output is correct
10 Correct 42 ms 6968 KB Output is correct
11 Correct 34 ms 5484 KB Output is correct
12 Correct 40 ms 6348 KB Output is correct
13 Correct 34 ms 4580 KB Output is correct
14 Correct 39 ms 6448 KB Output is correct
15 Correct 41 ms 6344 KB Output is correct
16 Correct 34 ms 4172 KB Output is correct
17 Correct 39 ms 5808 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 39 ms 3784 KB Output is correct
2 Correct 46 ms 6780 KB Output is correct
3 Correct 39 ms 6684 KB Output is correct
4 Correct 38 ms 4572 KB Output is correct
5 Correct 40 ms 5868 KB Output is correct
6 Correct 37 ms 4940 KB Output is correct
7 Correct 44 ms 5932 KB Output is correct
8 Correct 33 ms 4600 KB Output is correct
9 Correct 35 ms 4556 KB Output is correct
10 Correct 42 ms 6968 KB Output is correct
11 Correct 34 ms 5484 KB Output is correct
12 Correct 40 ms 6348 KB Output is correct
13 Correct 34 ms 4580 KB Output is correct
14 Correct 39 ms 6448 KB Output is correct
15 Correct 41 ms 6344 KB Output is correct
16 Correct 34 ms 4172 KB Output is correct
17 Correct 39 ms 5808 KB Output is correct
18 Incorrect 40 ms 5956 KB Output isn't correct
19 Halted 0 ms 0 KB -