QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#317009#6692. Building CompanysirsaksalotWA 45ms8680kbC++172.4kb2024-01-28 11:37:582024-01-28 11:37:58

Judging History

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

  • [2024-01-28 11:37:58]
  • 评测
  • 测评结果:WA
  • 用时:45ms
  • 内存:8680kb
  • [2024-01-28 11:37:58]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define   ll long long
#define ull unsigned ll
#define  pll pair<ll,ll>
#define   vl vector<ll>
#define vpll vector<pll>
#define  tll tuple<ll,ll,ll>
#define  vvl vector<vl>
#define   pb push_back
#define    all(x) (x).begin(),(x).end()
#define     sz(a) (ll) ((a).size())
template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.first << ", " << p.second << ')'; }
template<typename T_container, typename T = typename enable_if<!is_same<T_container, string>::value, typename T_container::value_type>::type> ostream& operator<<(ostream &os, const T_container &v) { os << '{'; string sep; for (const T &x : v) os << sep << x, sep = ", "; return os << '}'; } 
void dbg_out() { cerr << endl; }
template<typename Head, typename... Tail> void dbg_out(Head H, Tail... T) { cerr << ' ' << H; dbg_out(T...); }
#define dbg(...) cerr << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)
 

void solve(){
    ll n; cin>>n;
    vpll cur(n);
    for(auto& [a,b]:cur){
        cin>>a>>b;
    } sort(all(cur));
    map<ll,ll> mp;
    for(ll i=0;i<n;++i){mp[cur[i].first]=i;} 
    ll q; cin>>q;
    vl rem(q);
    vector<vpll> reward(q), cost(n);
    queue<ll> Q;
    ll ans = 0;
    for(ll i=0;i<q;++i){
        ll cnt; cin>>cnt;
        rem[i] = cnt;
        if(!cnt) Q.push(i),ans++;
        for(ll j=0;j<cnt;++j){
            ll a,b; cin>>a>>b;
            cost[mp[a]].pb({b,i});
        } 
        cin>>cnt;
        reward[i].resize(cnt);
        for(auto& [a,b]:reward[i]){ cin>>a>>b; a= mp[a]; } 
    } 
    vector<queue<pll>> cq(n);
    for(ll i=0;i<n;++i){
        auto &vv = cost[i];
        auto &qq = cq[i];
        sort(all(vv));
        for(auto j:vv) qq.push(j);
    } 
    do {
        // update
        while(Q.size()){
            ll i = Q.front(); Q.pop();
            for(auto [a,b]:reward[i]){
                cur[a].second+=b;
            }
        }
        // get
        for(ll i=0;i<n;++i){
            ll me = cur[i].second;
            auto &qq = cq[i];
            while(qq.size()){
                auto [x,j] = qq.front();
                if(x>me) break;
                qq.pop();
                if(!--rem[j])Q.push(j),ans++;
            }
        } 
    } while(Q.size());
    cout<<ans<<'\n';
}

int main(){
    ios::sync_with_stdio(0);cin.tie(0);
    ll t=1;
    while(t-->0){ solve();cerr<<"⋆⇝\n";}
}

詳細信息

Test #1:

score: 100
Accepted
time: 1ms
memory: 3832kb

input:

2 2 1 1 2
5
1 3 1
0
2 1 1 2 1
2 3 2 2 1
3 1 5 2 3 3 4
1 2 5
3 2 1 1 1 3 4
1 1 3
0
1 3 2

output:

4

result:

ok 1 number(s): "4"

Test #2:

score: 0
Accepted
time: 1ms
memory: 3820kb

input:

3 610031727 590328742 816793299 18485566 654221125 47823436
10
3 610031727 224714165 816793299 491951703 654221125 593479446
1 610031727 538596643
1 610031727 551036304
3 816793299 262985484 610031727 52580932 654221125 424397787
1 654221125 889197190
3 654221125 126924193 610031727 963399336 816793...

output:

10

result:

ok 1 number(s): "10"

Test #3:

score: 0
Accepted
time: 1ms
memory: 3544kb

input:

10 720543365 814021419 777649737 273919247 339754140 472967790 545693058 298289557 949226024 176807538 267294560 819212220 337794335 504610276 137418995 614590802 632556957 783062334 587607535 115519693
100
5 949226024 327424834 777649737 117746775 137418995 152960310 720543365 423301366 267294560 4...

output:

100

result:

ok 1 number(s): "100"

Test #4:

score: 0
Accepted
time: 1ms
memory: 3716kb

input:

33 598906111 952747266 214206082 308472115 773699301 71970369 334282917 266176016 861160505 745480638 397625705 130382274 75028923 106125916 739923352 754152044 493886549 212094717 352869179 727757279 697376464 343501623 916521518 80952344 90959088 722016125 286878647 329186592 770901193 30277256 92...

output:

100

result:

ok 1 number(s): "100"

Test #5:

score: -100
Wrong Answer
time: 45ms
memory: 8680kb

input:

380 562284409 583959039 705240193 694592025 91058796 151967354 775570098 571811699 457579493 117213529 684664737 33837962 60865228 186423701 316573783 868301583 744570505 934432338 790259030 364551324 145817136 961903964 737096543 759008968 865899868 681823261 273067044 247683791 186025557 756452454...

output:

1000

result:

wrong answer 1st numbers differ - expected: '992', found: '1000'