DID : PS 1문제 (2023/04/10)

DID : PS 1문제 (2023/04/10)

시험기간 - 빠르게 솔브드 스트릭만 유지

BOJ 23254 나는 기말고사형 인간이야
간단한 문제. 같은 종류의 공부를 다른 시간에 하더라고 관계가 없으니까, 그 시간에 할 수 있는 최대의 효율을 이끌어 내면 된다. 즉, 각 시간에 최대의 점수를 얻으면 되므로 간단한 그리디 문제. 솔브드 티어 골드는 솔직히 뻥튀기 같다.

#include<bits/stdc++.h>
using namespace std;
int a[(int)2e5+7],b[(int)2e5+7];
priority_queue<pair<int,int> > pq;
int main()
{
    int n,m; scanf("%d %d", &n,&m);
    n *= 24;
    for(int i = 1; i <= m; i++) scanf("%d", a+i);
    for(int i = 1; i <= m; i++) scanf("%d", b+i);

    int ans = 0;
    for(int i = 1; i <= m; i++)
    {
        pq.push({b[i], (100-a[i])/b[i]});
        pq.push({(100-a[i]) - ((100-a[i])/b[i])*b[i], 1});
        ans += a[i];
    }
    while(!pq.empty() and n)
    {
        auto i = pq.top();
        pq.pop();
        if(i.second > n) ans += i.first * n, n = 0;
        else ans += i.first * i.second, n -= i.second;
    }
    printf("%d", ans);
}