작성일 :

문제 링크

29790번 - 임스의 메이플컵

설명

백준 해결 문제 수 n, 메이플 유니온 u, 레벨 l이 주어질 때, 두 가지 조건을 확인하여 결과를 출력하는 문제입니다.


조건1은 n ≥ 1000이고, 조건2는 u ≥ 8000 또는 l ≥ 260입니다. 두 조건을 모두 만족하면 Very Good, 조건1만 만족하면 Good, 아니면 Bad를 출력합니다.


접근법

먼저 n이 1000 이상인지 확인합니다. 이후 u가 8000 이상이거나 l이 260 이상인지 확인합니다.


두 조건의 만족 여부에 따라 결과를 출력합니다.


Code

C#

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
using System;

class Program {
  static void Main() {
    var parts = Console.ReadLine()!.Split();
    var n = int.Parse(parts[0]);
    var u = int.Parse(parts[1]);
    var l = int.Parse(parts[2]);

    var cond1 = n >= 1000;
    var cond2 = u >= 8000 || l >= 260;

    if (cond1 && cond2) Console.WriteLine("Very Good");
    else if (cond1) Console.WriteLine("Good");
    else Console.WriteLine("Bad");
  }
}

C++

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#include <bits/stdc++.h>
using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);

  int n, u, l; cin >> n >> u >> l;

  bool cond1 = n >= 1000;
  bool cond2 = (u >= 8000) || (l >= 260);

  if (cond1 && cond2) cout << "Very Good\n";
  else if (cond1) cout << "Good\n";
  else cout << "Bad\n";

  return 0;
}

Tags: 29790, BOJ, C#, C++, 구현, 백준, 알고리즘

Categories: ,