103902024-04-01 18:40:42MagyarKendeSZLGJárdakövezés (75 pont)cpp17Accepted 75/754ms6792 KiB
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main() {
    int N;
    cin >> N;
    vector<array<ll, 2>> dp(N + 1, {INT_MAX, INT_MAX});
    dp[0] = {0, 0};
    dp[2] = {1, 0};
    if (N > 2) dp[3] = {0, 1};
    for (int i = 3; i <= N; i++) {
        ll a = dp[i - 2][0] + dp[i - 2][1],
           b = dp[i - 3][0] + dp[i - 3][1];
        if (a < b) {
            dp[i][0] = dp[i - 2][0] + 1;
            dp[i][1] = dp[i - 2][1];
        } else {
            dp[i][0] = dp[i - 3][0];
            dp[i][1] = dp[i - 3][1] + 1;
        }
    }
    cout << dp[N][0] << " " << dp[N][1];
}
SubtaskSumTestVerdictTimeMemory
base75/75
1Accepted0/03ms1812 KiB
2Accepted0/04ms4924 KiB
3Accepted3/33ms2224 KiB
4Accepted3/33ms2436 KiB
5Accepted3/33ms2656 KiB
6Accepted3/33ms2880 KiB
7Accepted3/33ms3112 KiB
8Accepted4/43ms3456 KiB
9Accepted4/43ms3476 KiB
10Accepted4/43ms3552 KiB
11Accepted4/43ms3548 KiB
12Accepted4/43ms3580 KiB
13Accepted4/43ms3672 KiB
14Accepted4/43ms3692 KiB
15Accepted4/43ms3940 KiB
16Accepted4/43ms4336 KiB
17Accepted4/43ms4480 KiB
18Accepted4/44ms6176 KiB
19Accepted4/44ms6572 KiB
20Accepted4/44ms6700 KiB
21Accepted4/44ms6792 KiB
22Accepted4/44ms6792 KiB