답안 #624825

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
624825 2022-08-08T19:47:31 Z paulica Rabbit Carrot (LMIO19_triusis) C++14
0 / 100
1 ms 212 KB
#include <bits/stdc++.h>

using namespace std;
#define lli long long int
const int N = 7000;
int t, n, m;
vector<pair<int, int> >v;
int a[N], b[N];
int dp[N][N];
int sol;

void solve () {
    cin >> n >> m;
    int l = 0, r;

    for (int i = 1; i <= n; i++) {
        cin >> a[i];
        b[i] = a[i];
    }
    if (a[1] > m) {
        b[1] = m;
    }
    for (int i = 1; i < n; i++) {
        if (b[i+1]-b[i] <= m) continue;
        if (b[i+1]-b[i-1] <= 2*m) {
            b[i] = (b[i+1]+b[i-1])/2;
            continue;
        }
        b[i+1] = b[i]+m;
    }
    for (int i = 1; i <= n; i++) {
        if (a[i] != b[i]) sol++;
    }
    cout << sol;

return;
}

int main () {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
	solve();

return 0;
}
/*
13 1
2 3 4 6 9 10 3 5 1 3 0 1 4


*/

Compilation message

triusis.cpp: In function 'void solve()':
triusis.cpp:14:9: warning: unused variable 'l' [-Wunused-variable]
   14 |     int l = 0, r;
      |         ^
triusis.cpp:14:16: warning: unused variable 'r' [-Wunused-variable]
   14 |     int l = 0, r;
      |                ^
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 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 0 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 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 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 0 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 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 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 0 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 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 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 0 ms 212 KB Output is correct
12 Incorrect 0 ms 212 KB Output isn't correct
13 Halted 0 ms 0 KB -