답안 #1108176

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1108176 2024-11-03T08:31:39 Z mispertion Measures (CEOI22_measures) C++17
0 / 100
1500 ms 1012 KB
#include<bits/stdc++.h>

using namespace std;
#pragma GCC optimize("O1")

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
#define F first
#define S second

const ld PI = 3.1415926535;
const int N = 5e5 + 2;
const int M = 1e7 + 1;
int mod = 998244353;
const int infi = INT_MAX;
const ll infl = LLONG_MAX;

int mult(int a, int b) {
    return a * 1LL * b % mod;
}

int sum(int a, int b) {
    if (a + b < 0)
        return a + b + mod;
    if (a + b >= mod)
        return a + b - mod;
    return a + b;
}


ll binpow(ll a, ll n) {
    if (n == 0)
        return 1;
    if (n % 2 == 1) {
        return binpow(a, n - 1) * a % mod;
    } else {
        ll b = binpow(a, n / 2);
        return b * b % mod;
    }
}

int n, m;
ld d;
vector<ld> x;

ld getans(){
    ld cur = x[0], ca = 0;
    for(int i = 1; i < x.size(); i++){
        if(x[i] + ca - cur >= d){
            ld nx;
            if(x[i] - cur >= d){
                nx = max(x[i] - ca, cur + d);
            }else{
                nx = cur + d;
            }
            cur = nx;
            continue;
        }
        ld ad = (d - x[i] - ca + cur) / 2;
        cur = cur - ad + d;
        ca += ad;
    }
    return ca;
}

void solve() {
    cin >> n >> m >> d;
    for(int i = 1; i <= n; i++){
        int ps;
        cin >> ps;
        x.push_back((ld)ps);
    }
    for(int i = 1; i <= m; i++){
        int ps;
        cin >> ps;
        x.push_back((ld)ps);
        sort(x.begin(), x.end());
        cout << getans() << '\n';
    }
}

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int t = 1;
    //cin >> t;
    while (t--) {
        solve();
    }
    return 0;
}

Compilation message

Main.cpp: In function 'ld getans()':
Main.cpp:50:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long double>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   50 |     for(int i = 1; i < x.size(); i++){
      |                    ~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 336 KB Output is correct
2 Incorrect 2 ms 552 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 336 KB Output is correct
2 Incorrect 2 ms 552 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1531 ms 1012 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1531 ms 1012 KB Time limit exceeded
2 Halted 0 ms 0 KB -