제출 #1339030

#제출 시각아이디문제언어결과실행 시간메모리
1339030po_rag526Sails (IOI07_sails)C++20
0 / 100
1 ms344 KiB
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
struct hk
{
    ll h;
    ll k;
};
bool boolm(hk a, hk b) 
{
    return a.h < b.h;
}
int main() 
{
    ll n;
    vector<hk> vec(n);
    ll maxh = 0;
    for (ll i = 0; i < n; i++) 
    {
        cin >> vec[i].h;
        cin >> vec[i].k;
        if (vec[i].h > maxh)
        {
            maxh = vec[i].h;
        } 
    }
    sort(vec.begin(), vec.end(), boolm);
    vector<int> veca(maxh + 1, 0);
    for (ll i = 0; i < n; i++) 
    {
        vector<pair<int, int>> vecb;
        for (ll h = 1; h <= vec[i].h; h++) 
        {
            vecb.push_back({veca[h], h});
        }
        sort(vecb.begin(), vecb.end());
        for (ll j = 0; j < vec[i].k; j++) 
        {
            veca[vecb[j].second]++;
        }
    }
    ll tot = 0;
    for (int i = 1; i <= maxh; i++)
    {
        ll c = veca[i];
        tot += (c * (c - 1 )) / 2;
    }
    cout << tot << endl;
    return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...