Submission #1118165

# Submission time Handle Problem Language Result Execution time Memory
1118165 2024-11-25T04:44:40 Z who Measures (CEOI22_measures) C++17
0 / 100
201 ms 21064 KB
#include <bits/stdc++.h>

using namespace std;

#define task "application"
#define etr "\n"
#define ll long long
#define int long long
#define ld long double
#define pii pair<int,int>
#define pli pair<long long,int>
#define pll pair<long long, long long>
#define fi first
#define se second
#define bg begin
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define lwb lower_bound
#define upb upper_bound
#define range(x, l, r) x+l, x+1+r
#define all(x) (x).bg(), (x).end()
#define compact(x) x.resize(unique(all(x)) - (x).bg())
#define sq(x) ((x)*(x))

auto start = chrono::high_resolution_clock::now();

void start_timer()
{
    start = chrono::high_resolution_clock::now();
}

ld elapsed()
{
    auto current = chrono::high_resolution_clock::now();
    ld duration = chrono::duration_cast<chrono::nanoseconds>(current - start).count();
    return duration / 1e9;
}
void freop()
{
    freopen(task".inp", "r", stdin);
    freopen(task".out", "w", stdout);
}

template<class U, class V> istream& operator >> (istream& in, pair<U, V>& p)
{
    in >> p.fi >> p.se;
    return in;
}

template<class U, class V> ostream& operator << (ostream& out, pair<U, V> p)
{
    out << "{" << p.fi << ' ' << p.se << "}";
    return out;
}

template<class T> ostream& operator << (ostream& out, vector<T>& v)
{
    out << "{";
    for (int i=0; i<v.size(); i++)
    {
        out << v[i];
        if (i != v.size() - 1) out << ", ";
    }

    out << "}";
    return out;
}

const int N=2e5, M=1e5, mod=1e9+7;

int n, m, d;
ll res = 0;
multiset<int> points, dist;

void addPoint(int x)
{
    auto ptr = points.upb(x);

    if (ptr != points.end() && ptr != points.begin())
    {
        int len = *ptr - *prev(ptr);
        dist.erase(dist.find(len));

        res -= max(0LL, d - len);
    }

    if (ptr != points.end())
    {
        int len = *ptr - x;
        dist.insert(len);
        res += max(0LL, d - len);
    }

    if (ptr != points.begin())
    {
        int len = x - *prev(ptr);
        dist.insert(len);
        res += max(0LL, d - len);
    }

    points.insert(x);
}

void process()
{
    cin >> n >> m >> d;

    for (int i=1; i<=n; i++)
    {
        int x;
        cin >> x;

        addPoint(x);
    }

    for (int i=1; i<=m; i++)
    {
        int x;
        cin >> x;

        addPoint(x);

        if (res & 1) cout << res/2 << ".5" << ' ';
        else cout << res/2 << ' ';
    }
}

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    //freop();

    int t=1; //cin >> t;
    while (t--) process();

    return 0;
}

Compilation message

Main.cpp: In function 'void freop()':
Main.cpp:42:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   42 |     freopen(task".inp", "r", stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:43:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   43 |     freopen(task".out", "w", stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 592 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 592 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 201 ms 21064 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 201 ms 21064 KB Output isn't correct
2 Halted 0 ms 0 KB -