728x90
반응형
https://www.acmicpc.net/problem/12018
12018번: Yonsei TOTO
연세대학교 수강신청이 얼마 전부터 바뀌어, 마일리지 제도로 바뀌었다. 이 제도는 각각의 학생들에게 마일리지를 주어 듣고 싶은 과목에 마일리지를 과목당 1~36을 분배한다. 그리고 모두 분배
www.acmicpc.net
/******************************************************************************
Online C++ Compiler.
Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.
*******************************************************************************/
#include <iostream>
#include<vector>
#include<queue>
using namespace std;
priority_queue<int,vector<int>,greater<int>>pq;
int main()
{
int n,m;//과목수, 마일리지
cin>>n>>m;
int p,l; //수강신청한 사람수, 수강인원
for(int i=0;i<n;i++){
cin>>p>>l;
priority_queue<int,vector<int>,less<int>>tmp;
int t;
for(int j=0;j<p;j++){
cin>>t;
tmp.push(t);
}
if(p<l){ //마일리지 1개
pq.push(1);
}
else{
int s=l-1;
while(s--){
tmp.pop();
}
pq.push(tmp.top());
}
}
int cnt=0;
//1 14 20 25 36
while(1){
if((m-pq.top())>=0){
cnt++;
m-=pq.top();
pq.pop();
}
else{
break;
}
if(pq.empty())break;
}
cout<<cnt;
return 0;
}
728x90
반응형
'하루 1문제 챌린지 > Silver3' 카테고리의 다른 글
백준 3273번 두 수의 합(C++) (1) | 2024.03.02 |
---|---|
백준 1448번 삼각형 만들기(C++) (0) | 2024.02.13 |
백준 2503번 숫자야구 (C++) (0) | 2024.02.12 |
백준 3077번 임진왜란 (C++) (1) | 2024.02.12 |
백준 15657번 N과 M(8) C++ (0) | 2024.01.31 |