QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#721757#9588. 可重集合mojo__hugoTL 1ms3732kbC++20680b2024-11-07 16:45:552024-11-07 16:45:55

Judging History

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

  • [2024-11-07 16:45:55]
  • 评测
  • 测评结果:TL
  • 用时:1ms
  • 内存:3732kb
  • [2024-11-07 16:45:55]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define endl '\n'
using PII=pair<int,int>;

const int N=1e6+5;

void solve(){
    int q;
    cin>>q;
    multiset<int>st;
    while(q--){
        int op,x;
        cin>>op>>x;
        if(op==1){
            st.insert(x);
        }
        else {
            st.erase(st.find(x));
        }
        bitset<500001>bt;
        bt[0]=1;
        for(auto i:st){
            bt|=bt<<i;
        }
        cout<<bt.count()-1<<endl;
    }
}

signed main(){
    // freopen("data.in","r",stdin);
    ios::sync_with_stdio(0),cin.tie(0);
    int t=1;
    // cin>>t;
    while(t--)solve();
}

詳細信息

Test #1:

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

input:

4
1 100
1 999
1 10
2 100

output:

1
3
7
3

result:

ok 4 lines

Test #2:

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

input:

7
1 1
1 2
1 1
1 4
1 5
2 1
2 4

output:

1
3
4
8
13
12
7

result:

ok 7 lines

Test #3:

score: -100
Time Limit Exceeded

input:

5000
1 132200
2 132200
1 304115
1 119865
1 7246
1 23773
1 6583
2 6583
2 119865
1 13380
1 38501
2 7246
1 115933
2 115933
1 52649
1 48334
1 2824
1 9919
2 2824
1 9007
1 309
2 304115
1 41830
2 9919
1 153380
1 100177
1 2775
2 13380
1 2913
1 16644
1 1437
2 9007
2 309
1 10921
1 1853
1 170
2 23773
1 561
1 2...

output:


result: