[백준/30969] 진주로 가자! (Hard) (C++/실버5)

2025. 12. 1. 16:48·Problem Solving/Baekjoon

https://www.acmicpc.net/problem/30969


메모리 제한으로 까다로운 문제였습니다.

빈도 배열을 활용하여 해결했습니다.

#include <iostream>
#include <vector>
using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
    int N; cin >> N;
    long long jinjuP = 1001;
    int result = 0;
    vector<int> v(1001, 0);
    while(N--)
        {
            string name; long long price;
            cin >> name >> price;
            if (price > 1000) result++;
            else v[price]++;
            if (name == "jinju")
            {
                jinjuP = price;
            }
        }
    
    for (int i=0; i<1001; i++)
        {
            if (i > jinjuP) result += v[i];
        }
    cout << jinjuP << "\n" << result;
}

 

'Problem Solving > Baekjoon' 카테고리의 다른 글

[백준/2170] 선 긋기 (C++/골드5)  (0) 2025.12.02
'Problem Solving/Baekjoon' 카테고리의 다른 글
  • [백준/2170] 선 긋기 (C++/골드5)
jabgok
jabgok
게임개발 블로그입니다
  • jabgok
    잡곡의 게임개발
    jabgok
  • 전체
    오늘
    어제
    • 분류 전체보기 (65) N
      • Unity (24) N
        • Unity Core (기초 개념) (9) N
        • Unity Features (기능) (12)
        • UI & UX (2) N
        • Performance (최적화) (0)
        • Architecture (설계) (1)
      • C++ (28)
        • C++ Study (14)
        • C++ Data Structure (6)
        • C++ Algorithm (8)
      • C# (4)
        • C# Study (4)
      • Problem Solving (3)
        • Baekjoon (2)
        • Programmers (1)
      • Development & Workfow (6)
        • Tools (1)
        • Collaboration (1)
        • Code Quality (3)
        • Platform (1)
  • 인기 글

  • 최근 글

  • 최근 댓글

  • hELLO· Designed By정상우.v4.10.6
jabgok
[백준/30969] 진주로 가자! (Hard) (C++/실버5)
상단으로

티스토리툴바