Submission

Status:

PPPPPPPPPP

Subtask/Task Score:

100/100

Score: 100

User: vachirasawin

Problemset: เลขดวง

Language: cpp

Time: 0.002 second

Submitted On: 2026-03-13 15:36:57

// grader-chan
// c1_bkk66_4.cpp | c1_bkk66_4

#include <bits/stdc++.h>
using namespace std;

int N, M, K;
int calendar[6][7];

int dr[] = {+1, 0, -1, 0};
int dc[] = {0, +1, 0, -1};

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

    cin >> N >> M >> K;
    M--;

    int currDay = M, currWeek = 0;
    int r, c;
    for (int i = 1; i <= N; i++) {
        if (currDay == 7) {
            currDay = 0;
            currWeek++;
        }

        if (i == K) {
            r = currWeek;
            c = currDay;
        }

        calendar[currWeek][currDay] = i;
        currDay++;
    }

    int total = 0;
    for (int i = 0; i < 4; i++) {
        int nr = r + dr[i];
        int nc = c + dc[i];

        if (nr >= 0 && nr <= currWeek && nc >= 0 && nc < 7) total += calendar[nr][nc];
    }

    cout << total;

    return 0;
}