답안 #1081562

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1081562 2024-08-30T07:24:49 Z vjudge1 Measures (CEOI22_measures) C++17
0 / 100
1500 ms 348 KB
#include <bits/stdc++.h>
//#define int long long

using namespace std;

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using ld = long double;

const int mod = 1e9 + 7;
const int LOG = 20;
const int maxn = 1e5 + 5;

signed main() {
    ll n, m, d;
    cin >> n >> m >> d;

    vector<ll> a(n);
    for(ll &x : a) cin >> x;
    sort(a.begin(), a.end());

    while(m--) {
        ll x;
        cin >> x;
        a.push_back(x);
        sort(a.begin(), a.end());

        ld ans=1e18;

            for(int i=0; i+1<a.size(); i++) {
                ld res = 0;
                if(a[i+1] - a[i] < d) res = ld(d - a[i+1] + a[i]) / 2;
                ld res1=0, res2=0;
                for(int j=0; j+1<=i; j++) if(a[j+1] - a[j] < d) res1 += d - a[j+1] + a[j];
                for(int j=i+1; j+1<a.size(); j++) if(a[j+1] - a[j] < d) res2 += d - a[j+1] + a[j];
                ans = min(ans, res + max(res1, res2));
            }
            for(int i=0; i<a.size(); i++) {
                ld res1=0, res2=0;
                if(i && a[i] - a[i-1] < d) res1 += d - a[i] + a[i-1];
                if(i + 1 < a.size() && a[i+1] - a[i] < d) res2 += d - a[i+1] + a[i];
                for(int j=0; j+1<i; j++) if(a[j+1] - a[j] < d) res1 += d - a[j+1] + a[j];
                for(int j=i+1; j+1<a.size(); j++) if(a[j+1] - a[j] < d) res2 += d - a[j+1] + a[j]; 
                ans = min(ans, max(res1, res2));
            }

        cout << ans << " ";
    }

    return 0;
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:31:29: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   31 |             for(int i=0; i+1<a.size(); i++) {
      |                          ~~~^~~~~~~~~
Main.cpp:36:35: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   36 |                 for(int j=i+1; j+1<a.size(); j++) if(a[j+1] - a[j] < d) res2 += d - a[j+1] + a[j];
      |                                ~~~^~~~~~~~~
Main.cpp:39:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   39 |             for(int i=0; i<a.size(); i++) {
      |                          ~^~~~~~~~~
Main.cpp:42:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   42 |                 if(i + 1 < a.size() && a[i+1] - a[i] < d) res2 += d - a[i+1] + a[i];
      |                    ~~~~~~^~~~~~~~~~
Main.cpp:44:35: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   44 |                 for(int j=i+1; j+1<a.size(); j++) if(a[j+1] - a[j] < d) res2 += d - a[j+1] + a[j];
      |                                ~~~^~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 63 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 63 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1507 ms 344 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1507 ms 344 KB Time limit exceeded
2 Halted 0 ms 0 KB -