QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#744229#9730. Elevator IIshenchuan_fanCompile Error//C++202.1kb2024-11-13 21:14:382024-11-13 21:14:38

Judging History

你现在查看的是最新测评结果

  • [2024-11-13 21:14:38]
  • 评测
  • [2024-11-13 21:14:38]
  • 提交

answer

#include <bits/stdc++.h>
#define int long long

using namespace std;

void solve()
{
    int n, f;
    cin >> n >> f;
    multiset<array<int, 3>> se1;
    multiset<array<int, 3>> se2;
    multiset<array<int, 3>> se3;

    for (int i = 1; i <= n; i++)
    {
        int l, r;
        cin >> l >> r;
        if (l <= f && r >= f)
        {
            se2.insert({r, l, i});
        }
        else if (r < f)
        {
            se3.insert({r, l, i});
        }
        else
        {
            se1.insert({l, r, i});
        }
    }

    vector<int> ans;
    int tot = 0;
    bool ok=true;
    while (ans.size() != n)
    {
        if (se2.empty())
        {
            
            if (se1.size())
            {
                auto [l,r,pos]=*se1.begin();
                se2.insert({r,l,pos});
                se1.erase(se1.begin());
                continue;
            }

            if (se3.size())
            {
                for (auto it = se3.rbegin(); it != se3.rend(); it++)
                {
                    auto [r, l, pos] = *it;
                    ans.push_back(pos);
                    tot += r - l;
                }
            }
            break;
        }   
        auto it = se2.rbegin();
        auto [r, l, pos] = *it;
        tot+=max(r-l,r-f);
        f=max(r,f);
        ans.push_back(pos);
        f = r;
        se2.erase(--se2.end());
        for(auto it:se2){
            se3.insert(it);
        }
        se2.clear();
        for (auto it = se1.begin(); it != se1.end();)
        {
            auto nxt = it;
            nxt++;
            auto [l, r, pos] = *it;
            if (l > f)
            {
                it++;
                break;
            }
            else if (r <= f)
            {
                se3.insert({r,l,pos});
                se1.erase(it);
                it = nxt;
            }
            else
            {
                se2.insert({r,l,pos});
                se1.erase(it);
                it = nxt;
            }
        }
    }
    cout<<tot<<'\n';
    for(auto x:ans){
        cout<<x<<' ';
    }
    cout<<'\n';
}

Details

/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/13/../../../x86_64-linux-gnu/Scrt1.o: in function `_start':
(.text+0x24): undefined reference to `main'
collect2: error: ld returned 1 exit status