답안 #1102636

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1102636 2024-10-18T14:06:38 Z vladilius Measures (CEOI22_measures) C++17
0 / 100
100 ms 4624 KB
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define pb push_back
#define ff first
#define ss second

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    
    int n, m, d; cin>>n>>m>>d;
    vector<int> a;
    for (int i = 1; i <= n; i++){
        int x; cin>>x;
        a.pb(x);
    }
    
    if (m <= 10){
        while (m--){
            int x; cin>>x;
            a.pb(x);
            sort(a.begin(), a.end());
            
            ll mx = numeric_limits<ll> :: min(), j = -1, out = 0;
            for (int i = 0; i < a.size(); i++){
                ll v = a[i] - 1LL * i * d;
                if (v > mx){
                    mx = v;
                    j = i;
                }
                out = max(out, a[j] - a[i] + 1LL * d * (i - j));
            }
            cout<<1.0 * out / 2<<"\n";
        }
        return 0;
    }
    
    if (n) return 0;
    
    ll mx = numeric_limits<ll> :: min(), j = -1, px = -1, out = 0;
    for (int i = 0; i < m; i++){
        int x; cin>>x;
        ll v = x - 1LL * i * d;
        if (v > mx){
            mx = v;
            j = i;
            px = x;
        }
        out = max(out, px - x + 1LL * d * (i - j));
        cout<<1.0 * out / 2<<"\n";
    }
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:28:31: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   28 |             for (int i = 0; i < a.size(); i++){
      |                             ~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 340 KB Output is correct
2 Incorrect 1 ms 340 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 340 KB Output is correct
2 Incorrect 1 ms 340 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 82 ms 3220 KB Output is correct
2 Incorrect 100 ms 4624 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 82 ms 3220 KB Output is correct
2 Incorrect 100 ms 4624 KB Output isn't correct
3 Halted 0 ms 0 KB -