QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#808639#9870. Itemsucup-team1134WA 116ms8056kbC++233.0kb2024-12-10 22:46:282024-12-10 22:46:29

Judging History

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

  • [2024-12-10 22:46:29]
  • 评测
  • 测评结果:WA
  • 用时:116ms
  • 内存:8056kb
  • [2024-12-10 22:46:28]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
#define vi vector<int>
#define vl vector<ll>
#define vii vector<pair<int,int>>
#define vll vector<pair<ll,ll>>
#define vvi vector<vector<int>>
#define vvl vector<vector<ll>>
#define vvii vector<vector<pair<int,int>>>
#define vvll vector<vector<pair<ll,ll>>>
#define vst vector<string>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define mkunique(x) sort(all(x));(x).erase(unique(all(x)),(x).end())
#define fi first
#define se second
#define mp make_pair
#define si(x) int(x.size())
const int mod=998244353,MAX=200005;
const ll INF=15LL<<58;

bitset<MAX> mada,dp;
ll cost1[MAX],cost2[MAX],D[MAX];

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int Q;cin>>Q;
    while(Q--){
        ll N,M;cin>>N>>M;
        vl S(N);
        for(int i=0;i<N;i++){
            cin>>S[i];
        }
        sort(all(S));
        for(int i=1;i<N;i++){
            S[i]-=S[0];
        }
        M-=S[0]*N;
        S[0]=0;
        if(M<0){
            cout<<"No\n";
            continue;
        }
        if(S.back()==0){
            if(M==0) cout<<"Yes\n";
            else cout<<"No\n";
            continue;
        }
        
        int K=S.back();
        dp.reset();
        mada.reset();
        mada[0]=mada[K]=false;
        for(int i=1;i<K+K;i++){
            mada[i]=true;
        }
        for(int i=0;i<K;i++){
            cost1[i]=INF;
            cost2[i]=INF;
            D[i]=INF;
        }
        cost1[0]=0;
        cost2[0]=0;
        D[0]=0;
        for(ll x:S){
            if(x<K) dp[x]=1;
        }
        
        queue<int> Q;
        Q.push(0);
        while(!Q.empty()){
            int u=Q.front();Q.pop();
            auto nex=(dp<<u)&mada;
            while(1){
                int i=nex._Find_first();
                if(i<MAX){
                    i%=K;
                    if(mada[i]){
                        cost1[i]=cost1[u]+(i-u+K)%K;
                        cost2[i]=cost2[u]+(i-u+K)%K;
                        D[i]=D[u]+1;
                        mada[i]=false;
                        mada[i+K]=false;
                        Q.push(i);
                    }else if(D[i]==D[u]+1){
                        chmin(cost1[i],cost1[u]+(i-u+K)%K);
                        chmax(cost2[i],cost2[u]+(i-u+K)%K);
                    }
                    nex[i]=false;
                    nex[i+K]=false;
                }else{
                    break;
                }
            }
        }
        
        if(D[M%K]>=N||cost1[M%K]>M) cout<<"No\n";
        else{
            if(D[M%K]+(M-cost2[M%K])/K<=N) cout<<"Yes\n";
            else cout<<"No\n";
        }
    }
}



詳細信息

Test #1:

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

input:

4
5 25
0 0 0 0 5
5 11
4 4 4 5 5
5 0
1 2 3 4 5
5 25
0 1 2 3 4

output:

Yes
No
No
No

result:

ok 4 token(s): yes count is 1, no count is 3

Test #2:

score: 0
Accepted
time: 8ms
memory: 7740kb

input:

1314
1 0
0
1 0
1
1 1
0
1 1
1
2 0
0 0
2 0
0 1
2 0
0 2
2 0
1 0
2 0
1 1
2 0
1 2
2 0
2 0
2 0
2 1
2 0
2 2
2 1
0 0
2 1
0 1
2 1
0 2
2 1
1 0
2 1
1 1
2 1
1 2
2 1
2 0
2 1
2 1
2 1
2 2
2 2
0 0
2 2
0 1
2 2
0 2
2 2
1 0
2 2
1 1
2 2
1 2
2 2
2 0
2 2
2 1
2 2
2 2
2 3
0 0
2 3
0 1
2 3
0 2
2 3
1 0
2 3
1 1
2 3
1 2
2 3
2 0...

output:

Yes
No
No
Yes
Yes
Yes
Yes
Yes
No
No
Yes
No
No
No
Yes
No
Yes
No
No
No
No
No
No
Yes
Yes
Yes
Yes
Yes
Yes
Yes
No
No
No
No
No
No
Yes
No
Yes
No
No
No
Yes
No
No
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
No
No
No
Yes
No
No
No
Yes
No
No
No
Yes
Yes
Yes...

result:

ok 1314 token(s): yes count is 732, no count is 582

Test #3:

score: -100
Wrong Answer
time: 116ms
memory: 8056kb

input:

10000
4 1
0 0 0 0
4 1
0 0 0 1
4 1
0 0 0 2
4 1
0 0 0 3
4 1
0 0 0 4
4 1
0 0 1 0
4 1
0 0 1 1
4 1
0 0 1 2
4 1
0 0 1 3
4 1
0 0 1 4
4 1
0 0 2 0
4 1
0 0 2 1
4 1
0 0 2 2
4 1
0 0 2 3
4 1
0 0 2 4
4 1
0 0 3 0
4 1
0 0 3 1
4 1
0 0 3 2
4 1
0 0 3 3
4 1
0 0 3 4
4 1
0 0 4 0
4 1
0 0 4 1
4 1
0 0 4 2
4 1
0 0 4 3
4 1
0 ...

output:

No
Yes
No
No
No
Yes
Yes
Yes
Yes
Yes
No
Yes
No
No
No
No
Yes
No
No
No
No
Yes
No
No
No
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
No
Yes
No
No
No
Yes
Yes
Yes
Yes
Yes
No
Yes
No
No
No
No
Yes
No
No
No
No
Yes
No
No
No
No
Yes
No
No
No
Yes
Yes
Yes
Yes
...

result:

wrong answer expected YES, found NO [8170th token]