답안 #787635

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
787635 2023-07-19T10:33:32 Z Valters07 Measures (CEOI22_measures) C++14
0 / 100
1500 ms 1108 KB
#include <bits/stdc++.h>
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,popcnt,lzcnt")
#define fio ios_base::sync_with_stdio(0);cin.tie(0);
#define ll long long
#define en cin.close();return 0;
#define pb push_back
#define fi first//printf("%lli\n",cur);
#define se second//scanf("%lli",&n);
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
ll calc2(vector<int> a, int d)
{
    ll t = 0, mx = 0;
    for(int i = 1;i<a.size();i++)
    {
        t=max(0ll,t+(d-(a[i]-a[i-1])));
        mx=max(mx,t);
    }
    return mx;
}
ll calc(vector<int> a, ll d)
{
    vector<int> l, r;
    int n = a.size(), mid = n/2;
    for(int i = 0;i<n;i++)
        if(i<mid)
            l.pb(a[i]);
        else
            r.pb(a[i]);
    if(n%2)
        l.pb(a[mid]);
    reverse(l.begin(),l.end());
    for(auto &x:l)
        x=-x;
    return max(calc2(l,d),calc2(r,d))*2+(n%2==0?max(0ll,d-(a[mid]-a[mid-1])):0);
}
int main()
{
    fio
//    ifstream cin("in.in");
    int n, m, d;
    cin >> n >> m >> d;
    vector<int> a(n);
    for(auto &x:a)
        cin >> x;
    while(m--)
    {
        int x;
        cin >> x;
        a.pb(x);
        sort(a.begin(),a.end());
        ll res = calc(a,d);
        cout << res/2;
        if(res%2)
            cout << ".5";
        cout << " ";
    }
    return 0;
}

Compilation message

Main.cpp: In function 'long long int calc2(std::vector<int>, int)':
Main.cpp:15:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   15 |     for(int i = 1;i<a.size();i++)
      |                   ~^~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1566 ms 1108 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1566 ms 1108 KB Time limit exceeded
2 Halted 0 ms 0 KB -