답안 #805652

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
805652 2023-08-03T19:29:25 Z AmrT Rabbit Carrot (LMIO19_triusis) C++17
0 / 100
1 ms 320 KB
#include <bits/stdc++.h>
#define lop(i,a,b) for(ll i = a; i < b; i++)
#define alop(i,v) for(auto &i: v)
#define in(v) for(auto &i: v) cin >> i;
#define ll long long
#define endl '\n'
#define pb push_back
#define all(v) v.begin(),v.end()
#define mem(p, x) memset(p, x, sizeof(p))
using namespace std;
ll mod = 1e9 + 7;

ll ind(vector<ll> &v, int i){
    if(v.size() == 1){
        if(v[0] < i) return v[0];
        else return -1;
    }
    int res = lower_bound(all(v), i) - v.begin();

    if(res == v.size()) return *v.rbegin();
    else if(res == 0){
        if(v[res] < i) return v[res];
        else return -1;
    }
    else return v[res - 1];
}

signed main(){
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    int n, k; cin >> n >> k;
    ll arr[n + 1] = {}; 
    lop(i, 0, n) cin >> arr[i + 1];

    ll ans = 0;
    for(int i = 0; i <= n; i++){
        if(i == 0){
            if(arr[1] > k) ans++, arr[1] = k;
        }
        else if(i == n){
            if(arr[n - 1] + k < arr[n]) ans++;
        }
        else{
            if(arr[i] + k < arr[i + 1]) ans++, arr[i + 1] = arr[i] + k;
        }
    }
    
    cout << ans;

    return 0;
}

Compilation message

triusis.cpp: In function 'long long int ind(std::vector<long long int>&, int)':
triusis.cpp:20:12: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   20 |     if(res == v.size()) return *v.rbegin();
      |        ~~~~^~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 316 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 320 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Incorrect 0 ms 212 KB Output isn't correct
13 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 316 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 320 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Incorrect 0 ms 212 KB Output isn't correct
13 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 316 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 320 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Incorrect 0 ms 212 KB Output isn't correct
13 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 316 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 320 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Incorrect 0 ms 212 KB Output isn't correct
13 Halted 0 ms 0 KB -