답안 #1081561

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1081561 2024-08-30T07:22:39 Z vjudge1 Measures (CEOI22_measures) C++17
0 / 100
1500 ms 472 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>;

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());

        if(a.size() == 1) {
            cout << 0 << " ";
            continue;
        }

        //gi delime lugjeto na grupi
        //megju sekoja grupa se delat na edna strana samo
        //megju sve grupi sprotivna
        vector<long double> dp(a.size(), 1e15);
        dp[0] = 0;

        for(int i=1; i<a.size(); i++) {
            double sum = 0;
            for(int j=i; j>=0; j--) {
                double shit = 0;
                if(j > 0 && a[j] - a[j-1] < d) shit = double(d - a[j] + a[j-1]) / 2;
                if(j < i && a[j+1] - a[j] < d) sum += d - a[j] + a[j-1];
                if(j == 0) dp[i] = min(dp[i], sum + dp[j-1]);
                else dp[i] = min(dp[i], sum + shit + dp[j-1]);
            }
        }

        cout << dp[a.size()-1] << " ";
    }

    return 0;
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:39:23: 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=1; i<a.size(); i++) {
      |                      ~^~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 121 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 121 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1566 ms 472 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1566 ms 472 KB Time limit exceeded
2 Halted 0 ms 0 KB -