QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#846289#9990. 摊位分配CrysflyAC ✓1ms7660kbC++143.5kb2025-01-07 02:44:082025-01-07 02:44:08

Judging History

你现在查看的是测评时间为 2025-01-07 02:44:08 的历史记录

  • [2025-01-07 02:47:43]
  • 管理员手动重测该提交记录
  • 测评结果:AC
  • 用时:576ms
  • 内存:53304kb
  • [2025-01-07 02:44:08]
  • 评测
  • 测评结果:0
  • 用时:1ms
  • 内存:7660kb
  • [2025-01-07 02:44:08]
  • 提交

answer

// what is matter? never mind. 
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,sse4,popcnt,abm,mmx,avx,avx2")
#include<bits/stdc++.h>
#define For(i,a,b) for(int i=(a);i<=(b);++i)
#define Rep(i,a,b) for(int i=(a);i>=(b);--i)
#define ll long long
//#define ull unsigned long long
#define int long long
#define SZ(x) ((int)((x).size()))
#define ALL(x) (x).begin(),(x).end()
using namespace std;
inline int read()
{
	char c=getchar();int x=0;bool f=0;
	for(;!isdigit(c);c=getchar())f^=!(c^45);
	for(;isdigit(c);c=getchar())x=(x<<1)+(x<<3)+(c^48);
	return f?-x:x;
}

#define mod 1000000007
struct modint{
	unsigned int x;
	modint(int o=0){x=o;}
	modint &operator = (int o){return x=o,*this;}
	modint &operator +=(modint o){return x=x+o.x>=mod?x+o.x-mod:x+o.x,*this;}
	modint &operator -=(modint o){return x=x<o.x?x-o.x+mod:x-o.x,*this;}
	modint &operator *=(modint o){return x=1ll*x*o.x%mod,*this;}
	modint &operator ^=(int b){
		modint a=*this,c=1;
		for(;b;b>>=1,a*=a)if(b&1)c*=a;
		return x=c.x,*this;
	}
	modint &operator /=(modint o){return *this *=o^=mod-2;}
	friend modint operator +(modint a,modint b){return a+=b;}
	friend modint operator -(modint a,modint b){return a-=b;}
	friend modint operator *(modint a,modint b){return a*=b;}
	friend modint operator /(modint a,modint b){return a/=b;}
	friend modint operator ^(modint a,int b){return a^=b;}
	friend bool operator ==(modint a,modint b){return a.x==b.x;}
	friend bool operator !=(modint a,modint b){return a.x!=b.x;}
	bool operator ! () {return !x;}
	modint operator - () {return x?mod-x:0;}
	bool operator <(const modint&b)const{return x<b.x;}
};
inline modint qpow(modint x,int y){return x^y;}

vector<modint> fac,ifac,iv;
inline void initC(int n)
{
	if(iv.empty())fac=ifac=iv=vector<modint>(2,1);
	int m=iv.size(); ++n;
	if(m>=n)return;
	iv.resize(n),fac.resize(n),ifac.resize(n);
	For(i,m,n-1){
		iv[i]=iv[mod%i]*(mod-mod/i);
		fac[i]=fac[i-1]*i,ifac[i]=ifac[i-1]*iv[i];
	}
}
inline modint C(int n,int m){
	if(m<0||n<m)return 0;
	return initC(n),fac[n]*ifac[m]*ifac[n-m];
}
inline modint sign(int n){return (n&1)?(mod-1):(1);}

#define fi first
#define se second
#define pb push_back
#define mkp make_pair
typedef pair<int,int>pii;
typedef vector<int>vi;

#define maxn 5000005
#define inf 0x3f3f3f3f

int n,a[maxn],m,res[maxn];
struct node{
	int x,y,id;
	friend bool operator <(node a,node b){
		// b is q.top()
		if((__int128)a.x*(1ll<<b.y) != (__int128)b.x*(1ll<<a.y)) {
			return a.x*(1ll<<b.y) < (b.x)*(1ll<<a.y);
		}
		if((a.y==0) != (b.y==0)){
			return (a.y==0) < (b.y==0);
		}
		if(a.x != b.x){
			return a.x<b.x;
		}
		return a.id>b.id;
	}
};
priority_queue< node >q;
node t[maxn]; int len;

bool chk0(node a){
	return a.x < (1ll<<a.y);
}

int cc[maxn];

void work()
{
	n=read(),m=read();
	For(i,1,n)a[i]=read();
	For(i,1,n)q.push({a[i],0,i});
	while(q.size() && m){
		t[++len]=q.top(); q.pop();
		node tmp=t[len];
		res[tmp.id]++;
		tmp.y++;
		--m;
		q.push(tmp);
		if(!m) break;
		
		if(len>=n && chk0(t[len-n+1])){
		//	cout<<"QWQ "<<m<<endl;
			For(i,len-n+1,len) {
				int ps=i-(len-n+1)+1; // [1,n]
				int cnt=m/n + (m%n>=ps);
				res[t[i].id]+=cnt;
			}
			break;
		}
	}
	For(i,1,n)cout<<res[i]<<" "; cout<<endl;
}

signed main()
{
	int T=1;
	while(T--)work();
    return 0;
}
/*
9 105
801 919 210 101 417 713 304 613 921

1 1 1 1
1 1 2 1

1 1 1 0 0 1 1 0

0 1 1 1 1 1 1 4 4 5 8 9 9 
*/

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 7660kb

input:

100 100
33554430 66 536870909 268435454 536870911 253 67108859 261 33554428 536870908 536870909 257 67108869 132 33554429 67 134217731 67108867 124 133 33554428 62 67 27 29 67108862 268435456 34 512 251 28 67108859 36 268435459 67108863 33554437 260 252 33554431 536870914 268435458 536870916 3355443...

output:

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

result:

wrong answer 1st lines differ - expected: '0 0 4 3 4 0 1 0 0 4 4 0 2 0 0 ...0 3 1 3 0 0 0 0 2 0 1 0 0 0 0 4', found: '0 0 4 3 4 0 1 0 0 4 4 0 2 0 0 ... 3 1 3 0 0 0 0 2 0 1 0 0 0 0 4 '