QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#560577#3953. Jane EyreLaVuna47#TL 0ms3628kbC++172.9kb2024-09-12 16:40:452024-09-12 16:40:50

Judging History

This is the latest submission verdict.

  • [2024-09-12 16:40:50]
  • Judged
  • Verdict: TL
  • Time: 0ms
  • Memory: 3628kb
  • [2024-09-12 16:40:45]
  • Submitted

answer

/** gnu specific **/
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
/** contains everything I need in std **/
#include <bits/stdc++.h>

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(S) ((int)S.size())
#define FOR(i, n) for(int i = 0; i < n; ++i)
#define RFOR(i, n) for(int i = n-1; i >= 0; --i)
#define output_vec(vec) { FOR(i_, sz(vec)) cout << vec[i_] << ' '; cout << '\n'; }
#define x first
#define y second
#define pb push_back
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef vector<bool> vb;
typedef short si;
typedef unsigned long long ull;
typedef long double LD;
typedef pair<ull, ull> pull;
using namespace __gnu_pbds;
typedef tree<ll, null_type, less<>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
using namespace std;
#ifdef ONPC
mt19937 rnd(228);
#else
mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());
#endif


int solve()
{
    int n, m, k;
    if (!(cin >> n >> m >> k))
        return 1;
        
    set<pair<string, int>> s;
    s.insert(make_pair("\"Jane Eyre\"", k));
    FOR (i, n)
    {
        string full = "";
        string tmp;
        cin >> tmp;
        while (tmp.back() != '\"')
        {
            full += tmp;
            cin >> tmp;
        }
        full += tmp;
        int pages;
        cin >> pages;
        s.insert(make_pair(full, pages));
    }
    
    ll ans = 0;
    vector<pair<ll, pair<string, int>>> gg(m);
    FOR (i, m)
    {
        cin >> gg[i].x;
        string full = "";
        string tmp;
        cin >> tmp;
        while (tmp.back() != '\"')
        {
            full += tmp;
            cin >> tmp;
        }
        full += tmp;
        int pages;
        cin >> pages;
        gg[i].y.x = full;
        gg[i].y.y = pages;
    }
        
        
    int j = 0;
    while (1)
    {
        while (j < m && gg[j].x <= ans)
        {
            s.insert(gg[j].y);
            j++;
        }
        auto tp = s.begin();
        auto el = *tp;
        if (el.x == "\"Jane Eyre\"")
        {
            ans += el.y;
            break;
        }
        else
        {
            ans += el.y;
            s.erase(s.begin());
        }
        //cout << sz(s) << '\n';
        //cout << ans << '\n';
    }
    cout << ans << '\n';
    return 0;
}

int32_t main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int TET = 1e9;
    //cin >> TET;
    for (int i = 1; i <= TET; i++)
    {
        if (solve())
        {
            break;
        }
#ifdef ONPC
        cout << "__________________________" << endl;
#endif
    }
#ifdef ONPC
    cerr << endl << "finished in " << clock() * 1.0 / CLOCKS_PER_SEC << " sec" << endl;
#endif
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3628kb

input:

2 2 592
"Pride and Predjudice" 432
"Don Quixote" 863
863 "Great Gatsby" 218
1082 "Crime and Punishment" 545

output:

1673

result:

ok single line: '1673'

Test #2:

score: -100
Time Limit Exceeded

input:

10 10 50116
"0sHzkZ q jriAgwD3WXL" 72225
"r6QBE1wVEmZiM0tY Nnb" 66075
"I6P vym0M DntAv83NeD" 2926
"EJKCvB958OXibIVU6V8b" 59599
"Bm1sD2u 3i32wbCrMXbP" 97406
"l DyFdoVV 3BZ3pijw8A" 50291
"v s2v2DofsHcQ1GdJJdc" 97497
" s Yca  oEz5prWklLuN" 21457
"CfpaCUZfRhs18Mmi 4IF" 11100
" yODdnhrY7N60tC2CoSE" 94220...

output:


result: