QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#32214 | #2571. Aidana and Pita | RobeZH# | WA | 1902ms | 3808kb | C++ | 1.4kb | 2022-05-18 05:23:51 | 2022-05-18 05:23:52 |
Judging History
answer
#include<bits/stdc++.h>
#define rep(i,n) for(int i=1;i<=n;++i)
#define st first
#define nd second
using namespace std;
typedef long long ll;
typedef pair<int,int> pr;
const int N=30;
int a[N],n,cpy[N],t[N];
int now[N],s[N];
mt19937 rng(19260817);
int tmp[4],ans;
int it = 0;
bool should_stop() {
return (++it) % 10000 == 0 && (double)clock() / CLOCKS_PER_SEC > 1.9;
}
int main() {
scanf("%d",&n);
//n=20;
ans=1;
rep(i,n){
scanf("%d",a+i);
//a[i]=i*i;
cpy[i]=a[i];ans+=a[i];
}
while(true){
if(should_stop()) break;
shuffle(a+1,a+n+1,rng);
tmp[1]=tmp[2]=tmp[3]=0;
rep(i,n){
rep(j,3)if(tmp[j]<=tmp[j%3+1]&&tmp[j]<=tmp[(j%3+1)%3+1]){
tmp[j]+=a[i];
now[i]=j;
break;
}
}
int ret=0;
rep(i,3)ret=max(ret,abs(tmp[i]-tmp[i%3+1]));
if(ret<ans){
ans=ret;
rep(i,n)t[i]=cpy[i];
rep(i,n){
rep(j,n)if(t[j]==a[i]){
t[j]=0;
s[j]=now[i];
break;
}
}
}
}
//printf("%d\n",ans);
rep(i,n)printf("%d%c",s[i]," \n"[i==n]);
return 0;
}
/*
20
1 1 1 1 1
1 1 1 1 1
1 1 1 1 1
1 1 1 1 1
1 1 1 1 1
*/
詳細信息
Test #1:
score: 100
Accepted
time: 1847ms
memory: 3776kb
input:
5 2 3 1 4 2
output:
1 3 3 2 1
result:
ok answer is 0
Test #2:
score: 0
Accepted
time: 1872ms
memory: 3788kb
input:
6 3 2 5 3 4 2
output:
1 3 3 1 2 2
result:
ok answer is 1
Test #3:
score: 0
Accepted
time: 1825ms
memory: 3784kb
input:
3 2617460 3290620 1468912
output:
2 1 3
result:
ok answer is 1821708
Test #4:
score: 0
Accepted
time: 1898ms
memory: 3792kb
input:
25 6 6 7 8 5 10 5 7 10 10 4 4 5 8 1 6 3 1 9 4 10 7 8 4 5
output:
1 2 1 2 1 2 3 2 3 2 3 3 1 3 1 2 3 1 1 3 1 1 3 2 3
result:
ok answer is 0
Test #5:
score: 0
Accepted
time: 1898ms
memory: 3808kb
input:
25 8 2 2 9 9 10 3 5 9 1 2 5 8 1 4 8 4 3 6 2 8 8 4 2 2
output:
2 2 3 3 1 3 1 2 1 2 2 1 2 3 1 3 3 3 2 3 2 1 1 3 2
result:
ok answer is 1
Test #6:
score: 0
Accepted
time: 1902ms
memory: 3736kb
input:
25 9999996 9999999 9999991 9999991 9999999 9999997 9999991 9999993 9999992 10000000 9999991 10000000 9999996 9999997 9999993 9999992 9999990 9999991 9999997 10000000 9999998 9999990 9999993 9999990 9999999
output:
2 1 3 3 2 2 3 1 1 1 3 1 1 1 2 3 3 3 1 2 2 3 2 3 2
result:
ok answer is 9999943
Test #7:
score: 0
Accepted
time: 1885ms
memory: 3716kb
input:
25 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000
output:
1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1
result:
ok answer is 10000000
Test #8:
score: -100
Wrong Answer
time: 1890ms
memory: 3796kb
input:
25 4568194 6252832 2990361 6179671 5525735 3402540 12193 4812907 2393092 9823299 4089880 1724585 2200631 5143163 5750864 5341161 5957736 2310544 8033121 9675751 9295231 71902 6463783 7667395 5613033
output:
2 1 3 1 3 2 1 3 3 3 1 3 2 2 2 2 1 1 3 2 1 2 3 1 2
result:
wrong answer expected 49, found 1757