QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#573586#7628. Keyi LIkes ReadingrerebornzhouAC ✓970ms3868kbC++201.7kb2024-09-18 19:19:552024-09-18 19:19:56

Judging History

你现在查看的是测评时间为 2024-09-18 19:19:56 的历史记录

  • [2024-10-31 16:36:56]
  • 自动重测本题所有获得100分的提交记录
  • 测评结果:AC
  • 用时:969ms
  • 内存:3848kb
  • [2024-10-31 16:24:15]
  • hack成功,自动添加数据
  • (/hack/1093)
  • [2024-09-28 14:43:20]
  • 自动重测本题所有获得100分的提交记录
  • 测评结果:100
  • 用时:975ms
  • 内存:3852kb
  • [2024-09-28 14:42:48]
  • hack成功,自动添加数据
  • (/hack/923)
  • [2024-09-18 19:19:56]
  • 评测
  • 测评结果:100
  • 用时:970ms
  • 内存:3868kb
  • [2024-09-18 19:19:55]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define IOS std::ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
// #define int long long
#define ull unsigned long long
#define fi first
#define se second
#define pi pair<int,int>

const int N=1e6+10;
// const int INF=1e18;

int n,w;

int cnt[14];
int ans=1e9;

// void print(int t){
//     vector<int> vt;
//     for(int i=0;i<=12;i++){
//         vt.push_back(t%2);
//         t>>=1;
//     }
//     for(auto x:vt){
//         cout<<x;
//     }
//     cout<<"\n";
// }

void dfs(int t,int can){
    if(can==0){
        ans=min(ans,t);
        return;
    }
    if(t>=ans) return;
    int k=can;
    do{
        // cerr<<can<<" "<<k<<"\n";
        if(k==0) break;
        int sum=0;
        for(int i=0;i<13;i++){
            if((1ll<<i)&k){
                sum+=cnt[i+1];
            }
        }
        // print(k);
        // cout<<sum<<" "<<w<<"\n";
        if(sum<=w && t+1<=ans){
            // cout<<"in"<<"\n";
            dfs(t+1,can-k);
        }
    }while((k=(k-1)&can )!= can);
}

void solve(){
    cin>>n>>w;
    int maxn=0;
    for(int i=1;i<=n;i++){
        int t;
        cin>>t;
        maxn=max(maxn,t);
        cnt[t]++;
    }
    for(int i=1;i<=20000000;i++){
        int cc=1;
        int sum=0;
        for(int j=1;j<=maxn;j++){
            sum+=cnt[j];
            if(sum>w){
                cc++;
                sum=cnt[j];
            }
        }
        ans=min(ans,cc);
        swap(cnt[rand()%maxn+1],cnt[maxn]);
    }
    int can=(1ll<<maxn)-1;
    // dfs(0,can);
    cout<<ans<<"\n";
}

signed main(){
    IOS
    srand(time(0));
    int _=1;
    // cin>>_;
    while(_--){
        solve();
    }
}

这程序好像有点Bug,我给组数据试试?

详细

Test #1:

score: 100
Accepted
time: 157ms
memory: 3864kb

input:

5 4
1 2 1 2 1

output:

2

result:

ok single line: '2'

Test #2:

score: 0
Accepted
time: 865ms
memory: 3672kb

input:

76 10
1 1 2 2 2 2 2 2 2 2 2 3 4 4 4 4 5 5 5 5 5 5 5 5 6 6 6 6 6 6 6 6 6 6 8 8 9 9 9 9 9 9 9 9 10 10 10 10 10 10 10 11 11 11 11 11 11 12 12 12 12 12 12 12 12 12 13 13 13 13 13 13 13 13 13 13

output:

8

result:

ok single line: '8'

Test #3:

score: 0
Accepted
time: 857ms
memory: 3736kb

input:

73 10
1 1 1 1 1 1 1 1 2 2 2 2 2 2 4 4 4 4 4 4 4 4 5 5 5 5 5 5 5 5 5 5 6 6 6 6 6 6 6 6 6 6 7 7 7 7 7 8 8 9 9 9 9 9 9 9 10 10 11 11 11 11 11 12 12 12 12 12 13 13 13 13 13

output:

8

result:

ok single line: '8'

Test #4:

score: 0
Accepted
time: 797ms
memory: 3788kb

input:

81 10
1 1 1 1 1 1 2 2 2 2 2 2 2 2 3 4 4 4 4 4 4 4 4 4 5 5 5 5 5 5 5 5 5 5 6 7 7 7 7 7 7 7 7 7 7 8 8 8 8 8 8 8 8 8 9 9 9 10 11 11 11 11 11 11 11 11 12 12 12 12 12 12 12 12 13 13 13 13 13 13 13

output:

9

result:

ok single line: '9'

Test #5:

score: 0
Accepted
time: 970ms
memory: 3724kb

input:

63 10
1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 4 4 4 5 6 6 6 6 6 7 7 7 7 7 7 7 7 7 8 8 9 9 9 9 9 9 9 9 9 9 10 10 10 11 11 13 13 13 13 13 13 13 13 13 13

output:

7

result:

ok single line: '7'

Test #6:

score: 0
Accepted
time: 826ms
memory: 3668kb

input:

76 10
1 1 1 1 1 1 1 1 1 1 3 3 3 3 3 3 4 4 4 4 4 4 5 5 5 5 5 5 6 6 6 6 6 7 7 7 8 8 8 8 8 8 8 8 8 9 9 9 9 9 9 9 9 9 9 10 10 10 10 10 10 10 10 10 11 12 12 12 13 13 13 13 13 13 13 13

output:

9

result:

ok single line: '9'

Test #7:

score: 0
Accepted
time: 690ms
memory: 3660kb

input:

7879 1000
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...

output:

9

result:

ok single line: '9'

Test #8:

score: 0
Accepted
time: 900ms
memory: 3660kb

input:

6542 1000
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...

output:

7

result:

ok single line: '7'

Test #9:

score: 0
Accepted
time: 853ms
memory: 3812kb

input:

6948 1000
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...

output:

9

result:

ok single line: '9'

Test #10:

score: 0
Accepted
time: 824ms
memory: 3816kb

input:

7486 1000
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...

output:

9

result:

ok single line: '9'

Test #11:

score: 0
Accepted
time: 807ms
memory: 3672kb

input:

7524 1000
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...

output:

8

result:

ok single line: '8'

Test #12:

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

input:

24352 3500
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1...

output:

8

result:

ok single line: '8'

Test #13:

score: 0
Accepted
time: 872ms
memory: 3800kb

input:

24015 3500
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2...

output:

8

result:

ok single line: '8'

Test #14:

score: 0
Accepted
time: 932ms
memory: 3724kb

input:

18177 3500
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1...

output:

6

result:

ok single line: '6'

Test #15:

score: 0
Accepted
time: 914ms
memory: 3724kb

input:

19348 3500
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1...

output:

6

result:

ok single line: '6'

Test #16:

score: 0
Accepted
time: 827ms
memory: 3680kb

input:

25667 3500
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1...

output:

9

result:

ok single line: '9'

Test #17:

score: 0
Accepted
time: 373ms
memory: 3668kb

input:

30 18
1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 3 3 3 4 4 4 4 4 4 5 5 5 6 6 6

output:

2

result:

ok single line: '2'

Test #18:

score: 0
Accepted
time: 373ms
memory: 3712kb

input:

25 18
1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 3 3 4 4 5 5 6 6

output:

2

result:

ok single line: '2'

Test #19:

score: 0
Accepted
time: 357ms
memory: 3760kb

input:

12 4
1 2 3 4 4 4 5 5 5 6 6 6

output:

3

result:

ok single line: '3'

Test #20:

score: 0
Accepted
time: 774ms
memory: 3736kb

input:

7237 1000
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 ...

output:

9

result:

ok single line: '9'

Test #21:

score: 0
Accepted
time: 931ms
memory: 3684kb

input:

6157 1000
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...

output:

7

result:

ok single line: '7'

Test #22:

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

input:

9469 1000
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...

output:

11

result:

ok single line: '11'

Test #23:

score: 0
Accepted
time: 919ms
memory: 3796kb

input:

6601 1000
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...

output:

7

result:

ok single line: '7'

Test #24:

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

input:

8509 1000
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...

output:

11

result:

ok single line: '11'

Test #25:

score: 0
Accepted
time: 924ms
memory: 3800kb

input:

6044 1000
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...

output:

7

result:

ok single line: '7'

Test #26:

score: 0
Accepted
time: 870ms
memory: 3816kb

input:

6319 1000
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...

output:

7

result:

ok single line: '7'

Test #27:

score: 0
Accepted
time: 720ms
memory: 3868kb

input:

8001 1000
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...

output:

9

result:

ok single line: '9'

Test #28:

score: 0
Accepted
time: 946ms
memory: 3664kb

input:

5515 1000
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...

output:

6

result:

ok single line: '6'

Test #29:

score: 0
Accepted
time: 950ms
memory: 3668kb

input:

6054 1000
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...

output:

7

result:

ok single line: '7'

Extra Test:

score: 0
Extra Test Passed