QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#128704#6339. Cookieskshitij_sodani6 161ms992884kbC++142.5kb2023-07-21 15:01:352023-07-21 15:17:27

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-07-21 15:17:27]
  • 评测
  • 测评结果:6
  • 用时:161ms
  • 内存:992884kb
  • [2023-07-21 15:01:35]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define a first
#define b second
#define pb push_back
typedef long long llo;
#define endl '\n'

int n;
int it[15001];
int pre[1501];
int val[1501];
int dp[503][501][501];
int ba[503][501][501];
int pp[100001];
int vis[100001];
vector<int> fin[100001];
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin>>n;
	llo su=0;
	vector<pair<int,int>> ss;
	for(int i=0;i<n;i++){
		cin>>it[i];
		su+=it[i];
		ss.pb({-it[i],i});
		it[i]=-it[i];
	}
	sort(ss.begin(),ss.end());
	for(int j=0;j<ss.size();j++){
		pp[j]=ss[j].b;
	}
	sort(it,it+n);
	vector<int> ee;
	for(int i=0;i<n;i++){
		it[i]=-it[i];
		for(int j=0;j<it[i];j++){
			ee.pb(i);
		}
	}

	for(int i=0;i<n;i++){
		pre[i+1]=pre[i]+it[i];
	}
	for(int i=0;i<n;i++){
		for(int j=pre[i];j<pre[i+1];j++){
			val[j]=i;
		}
	}
	int m;
	cin>>m;
	for(int i=0;i<m;i++){
		int x;
		cin>>x;
		vis[x]=1;
	}
	for(int i=0;i<=n+1;i++){
		for(int j=0;j<=su;j++){
			for(int k=0;k<=su;k++){
				dp[i][j][k]=1e9;
				ba[i][j][k]=-1;
			}
		}
	}
	for(int i=0;i<=su;i++){
		dp[0][0][i]=0;
	}
	for(int i=0;i<=n;i++){
		for(int j=0;j<=su;j++){
			for(int k=0;k<=su;k++){
				if(dp[i][j][k]<=su){
					pair<int,int> ll={k,k};
					if(vis[i]==1){
						ll={0,k};
					}
					for(int ii=ll.a;ii<=ll.b;ii++){

						if(j+ii<=su){

							if(j+ii<su and it[val[j+ii]]>ii){

							}
							else{
								if(dp[i][j][k]+abs(ii-k)<dp[i+1][j+ii][ii]){
									ba[i+1][j+ii][ii]=k;
								}
								dp[i+1][j+ii][ii]=min(dp[i+1][j+ii][ii],dp[i][j][k]+abs(ii-k));
							}
						}
					}
				}
			}
		}
	}
	int ans=dp[n+1][su][0];

	/*for(int i=0;i<=n;i++){
		for(int k=0;k<=su;k++){
			ans=min(ans,dp[i][su][k]);
		}
	}*/

	//cout<<dp[3][7][1]<<":"<<endl;
	//cout<<dp[4][7][0]<<":"<<endl;
	if(ans>su){
		cout<<-1<<endl;
		return 0;
	}
	pair<pair<int,int>,int> cur={{n+1,su},0};
	vector<int> kk;
	kk.pb(0);
	for(int i=n;i>=1;i--){		
		int mm=ba[cur.a.a][cur.a.b][cur.b];
		cur.a.a--;
		cur.a.b-=cur.b;
		cur.b=mm;
		//if(cur.b>0){
			kk.pb(cur.b);
		//}
	}

	cout<<ans<<endl;
	reverse(kk.begin(),kk.end());

	int ind=0;

	for(int i=0;i<kk.size();i++){
		for(int j=0;j<kk[i];j++){
			//cout<<i<<":"<<j<<":"<<ee[ind]<<endl;
			fin[j].pb(ee[ind]);
			ind++;
		}
	}
	for(int j=0;j<ans;j++){
		cout<<fin[j].size()<<" ";
		for(auto i:fin[j]){		
			cout<<pp[i]+1<<" ";
		}
		cout<<endl;
	}
	/*for(auto j:kk){
		cout<<j<<",";
	}
	cout<<endl;
*/












	

 
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 6
Accepted

Test #1:

score: 6
Accepted
time: 3ms
memory: 13308kb

input:

1
1
1
1

output:

1
1 1 

result:

ok good!

Test #2:

score: 0
Accepted
time: 4ms
memory: 17148kb

input:

2
1 1
1
1

output:

2
1 1 
1 2 

result:

ok good!

Test #3:

score: 0
Accepted
time: 0ms
memory: 15748kb

input:

2
1 1
1
2

output:

1
2 1 2 

result:

ok good!

Test #4:

score: 0
Accepted
time: 0ms
memory: 15428kb

input:

2
1 1
2
1 2

output:

1
2 1 2 

result:

ok good!

Test #5:

score: 0
Accepted
time: 0ms
memory: 18012kb

input:

4
1 1 1 1
2
2 3

output:

2
2 1 3 
2 2 4 

result:

ok good!

Test #6:

score: 0
Accepted
time: 2ms
memory: 28400kb

input:

8
1 1 1 1 1 1 1 1
3
1 4 5

output:

2
4 1 3 5 7 
4 2 4 6 8 

result:

ok good!

Test #7:

score: 0
Accepted
time: 149ms
memory: 992016kb

input:

500
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 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:

500
1 1 
1 2 
1 3 
1 4 
1 5 
1 6 
1 7 
1 8 
1 9 
1 10 
1 11 
1 12 
1 13 
1 14 
1 15 
1 16 
1 17 
1 18 
1 19 
1 20 
1 21 
1 22 
1 23 
1 24 
1 25 
1 26 
1 27 
1 28 
1 29 
1 30 
1 31 
1 32 
1 33 
1 34 
1 35 
1 36 
1 37 
1 38 
1 39 
1 40 
1 41 
1 42 
1 43 
1 44 
1 45 
1 46 
1 47 
1 48 
1 49 
1 50 
1 51 ...

result:

ok good!

Test #8:

score: 0
Accepted
time: 116ms
memory: 991456kb

input:

500
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 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:

1
500 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 10...

result:

ok good!

Test #9:

score: 0
Accepted
time: 143ms
memory: 992056kb

input:

500
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 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:

2
250 1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39 41 43 45 47 49 51 53 55 57 59 61 63 65 67 69 71 73 75 77 79 81 83 85 87 89 91 93 95 97 99 101 103 105 107 109 111 113 115 117 119 121 123 125 127 129 131 133 135 137 139 141 143 145 147 149 151 153 155 157 159 161 163 165 167 169 171 173 1...

result:

ok good!

Test #10:

score: 0
Accepted
time: 143ms
memory: 992400kb

input:

500
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 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:

-1

result:

ok no solution

Test #11:

score: 0
Accepted
time: 142ms
memory: 992016kb

input:

500
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 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
46 1 12 23 34 45 56 67 78 89 100 111 122 133 144 155 166 177 188 199 210 221 232 243 254 265 276 287 298 309 320 331 342 353 364 375 386 397 408 419 430 441 452 463 474 485 496 
46 2 13 24 35 46 57 68 79 90 101 112 123 134 145 156 167 178 189 200 211 222 233 244 255 266 277 288 299 310 321 332 34...

result:

ok good!

Test #12:

score: 0
Accepted
time: 146ms
memory: 992008kb

input:

500
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 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:

250
2 1 251 
2 2 252 
2 3 253 
2 4 254 
2 5 255 
2 6 256 
2 7 257 
2 8 258 
2 9 259 
2 10 260 
2 11 261 
2 12 262 
2 13 263 
2 14 264 
2 15 265 
2 16 266 
2 17 267 
2 18 268 
2 19 269 
2 20 270 
2 21 271 
2 22 272 
2 23 273 
2 24 274 
2 25 275 
2 26 276 
2 27 277 
2 28 278 
2 29 279 
2 30 280 
2 31 ...

result:

ok good!

Test #13:

score: 0
Accepted
time: 125ms
memory: 963904kb

input:

484
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 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:

22
22 1 23 45 67 89 111 133 155 177 199 221 243 265 287 309 331 353 375 397 419 441 463 
22 2 24 46 68 90 112 134 156 178 200 222 244 266 288 310 332 354 376 398 420 442 464 
22 3 25 47 69 91 113 135 157 179 201 223 245 267 289 311 333 355 377 399 421 443 465 
22 4 26 48 70 92 114 136 158 180 202 22...

result:

ok good!

Test #14:

score: 0
Accepted
time: 129ms
memory: 983984kb

input:

495
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 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:

55
9 1 56 111 166 221 276 331 386 441 
9 2 57 112 167 222 277 332 387 442 
9 3 58 113 168 223 278 333 388 443 
9 4 59 114 169 224 279 334 389 444 
9 5 60 115 170 225 280 335 390 445 
9 6 61 116 171 226 281 336 391 446 
9 7 62 117 172 227 282 337 392 447 
9 8 63 118 173 228 283 338 393 448 
9 9 64 11...

result:

ok good!

Test #15:

score: 0
Accepted
time: 116ms
memory: 992536kb

input:

500
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 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:

4
125 1 5 9 13 17 21 25 29 33 37 41 45 49 53 57 61 65 69 73 77 81 85 89 93 97 101 105 109 113 117 121 125 129 133 137 141 145 149 153 157 161 165 169 173 177 181 185 189 193 197 201 205 209 213 217 221 225 229 233 237 241 245 249 253 257 261 265 269 273 277 281 285 289 293 297 301 305 309 313 317 32...

result:

ok good!

Test #16:

score: 0
Accepted
time: 152ms
memory: 991324kb

input:

499
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 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:

27
21 1 28 55 82 109 136 163 190 217 244 271 298 325 352 379 406 433 460 470 480 490 
21 2 29 56 83 110 137 164 191 218 245 272 299 326 353 380 407 434 461 471 481 491 
21 3 30 57 84 111 138 165 192 219 246 273 300 327 354 381 408 435 462 472 482 492 
21 4 31 58 85 112 139 166 193 220 247 274 301 32...

result:

ok good!

Test #17:

score: 0
Accepted
time: 132ms
memory: 992884kb

input:

499
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 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:

19
27 1 20 39 58 77 96 115 134 153 172 191 210 229 248 267 286 305 324 342 360 378 396 414 432 449 466 483 
27 2 21 40 59 78 97 116 135 154 173 192 211 230 249 268 287 306 325 343 361 379 397 415 433 450 467 484 
27 3 22 41 60 79 98 117 136 155 174 193 212 231 250 269 288 307 326 344 362 380 398 416...

result:

ok good!

Test #18:

score: 0
Accepted
time: 132ms
memory: 992328kb

input:

499
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 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
88 1 8 15 22 29 36 43 50 57 64 71 78 85 92 99 106 113 120 127 134 141 148 155 162 169 176 183 190 197 204 211 218 225 232 239 246 253 260 267 274 281 288 295 302 309 316 323 330 337 344 351 358 365 372 379 386 393 400 407 414 421 428 435 442 449 454 456 458 460 462 464 466 468 470 472 474 476 478 ...

result:

ok good!

Test #19:

score: 0
Accepted
time: 136ms
memory: 991488kb

input:

499
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 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:

4
243 1 5 9 13 17 21 25 29 33 37 41 45 49 53 57 61 65 69 73 77 81 85 89 93 97 101 105 109 113 117 121 125 129 133 137 141 145 149 153 157 161 165 169 173 177 181 185 189 193 197 201 205 209 213 217 221 225 227 229 231 233 235 237 239 241 243 245 247 249 251 253 255 257 259 261 263 265 267 269 271 27...

result:

ok good!

Test #20:

score: 0
Accepted
time: 154ms
memory: 991716kb

input:

499
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 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:

2
286 1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39 41 43 45 47 49 51 53 55 57 59 61 63 65 67 69 71 73 75 77 79 81 83 85 87 89 91 93 95 97 99 101 103 105 107 109 111 113 115 117 119 121 123 125 127 129 131 133 135 137 139 141 143 145 147 149 151 153 155 157 159 161 163 165 167 169 171 173 1...

result:

ok good!

Test #21:

score: 0
Accepted
time: 161ms
memory: 992496kb

input:

499
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 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:

-1

result:

ok no solution

Test #22:

score: 0
Accepted
time: 137ms
memory: 992000kb

input:

499
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 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:

-1

result:

ok no solution

Test #23:

score: 0
Accepted
time: 130ms
memory: 981292kb

input:

493
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 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:

17
35 1 18 35 52 69 86 103 120 137 154 171 188 205 222 239 256 273 290 307 318 329 340 351 362 373 384 395 406 417 428 439 450 461 472 483 
35 2 19 36 53 70 87 104 121 138 155 172 189 206 223 240 257 274 291 308 319 330 341 352 363 374 385 396 407 418 429 440 451 462 473 484 
35 3 20 37 54 71 88 105...

result:

ok good!

Test #24:

score: 0
Accepted
time: 144ms
memory: 979908kb

input:

493
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 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:

17
52 1 18 34 50 66 82 98 114 130 146 162 178 194 210 226 242 258 274 290 296 302 308 314 320 326 332 338 344 350 356 362 368 374 380 386 392 398 404 410 416 422 428 434 440 446 452 458 464 470 476 482 488 
52 2 19 35 51 67 83 99 115 131 147 163 179 195 211 227 243 259 275 291 297 303 309 315 321 32...

result:

ok good!

Test #25:

score: 0
Accepted
time: 132ms
memory: 981324kb

input:

493
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 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:

17
33 1 18 35 52 69 86 103 120 137 154 171 188 205 222 239 256 273 286 299 312 325 338 351 364 377 390 403 416 429 442 455 468 481 
33 2 19 36 53 70 87 104 121 138 155 172 189 206 223 240 257 274 287 300 313 326 339 352 365 378 391 404 417 430 443 456 469 482 
33 3 20 37 54 71 88 105 122 139 156 173...

result:

ok good!

Test #26:

score: 0
Accepted
time: 135ms
memory: 980748kb

input:

493
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 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:

17
67 1 18 35 52 69 86 103 120 137 154 171 188 205 222 239 256 273 279 285 291 297 303 309 315 321 327 333 339 345 351 357 363 369 375 381 387 393 399 405 411 417 423 429 435 441 447 453 459 465 471 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 
50 2 19 36 53 70 87 104 121 138 ...

result:

ok good!

Test #27:

score: 0
Accepted
time: 145ms
memory: 979676kb

input:

493
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 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:

17
33 1 18 35 52 69 86 103 120 137 154 171 188 205 222 239 256 273 286 299 312 325 338 351 364 377 390 403 416 429 442 455 468 481 
33 2 19 36 53 70 87 104 121 138 155 172 189 206 223 240 257 274 287 300 313 326 339 352 365 378 391 404 417 430 443 456 469 482 
33 3 20 37 54 71 88 105 122 139 156 173...

result:

ok good!

Subtask #2:

score: 0
Time Limit Exceeded

Test #28:

score: 7
Accepted
time: 1ms
memory: 13092kb

input:

1
15
1
1

output:

15
1 1 
1 1 
1 1 
1 1 
1 1 
1 1 
1 1 
1 1 
1 1 
1 1 
1 1 
1 1 
1 1 
1 1 
1 1 

result:

ok good!

Test #29:

score: 0
Accepted
time: 4ms
memory: 13664kb

input:

1
500
1
1

output:

500
1 1 
1 1 
1 1 
1 1 
1 1 
1 1 
1 1 
1 1 
1 1 
1 1 
1 1 
1 1 
1 1 
1 1 
1 1 
1 1 
1 1 
1 1 
1 1 
1 1 
1 1 
1 1 
1 1 
1 1 
1 1 
1 1 
1 1 
1 1 
1 1 
1 1 
1 1 
1 1 
1 1 
1 1 
1 1 
1 1 
1 1 
1 1 
1 1 
1 1 
1 1 
1 1 
1 1 
1 1 
1 1 
1 1 
1 1 
1 1 
1 1 
1 1 
1 1 
1 1 
1 1 
1 1 
1 1 
1 1 
1 1 
1 1 
1 1 
1...

result:

ok good!

Test #30:

score: 0
Accepted
time: 11ms
memory: 25604kb

input:

1
3000
1
1

output:

3000
1 1 
1 1 
1 1 
1 1 
1 1 
1 1 
1 1 
1 1 
1 1 
1 1 
1 1 
1 1 
1 1 
1 1 
1 1 
1 1 
1 1 
1 1 
1 1 
1 1 
1 1 
1 1 
1 1 
1 1 
1 1 
1 1 
1 1 
1 1 
1 1 
1 1 
1 1 
1 1 
1 1 
1 1 
1 1 
1 1 
1 1 
1 1 
1 1 
1 1 
1 1 
1 1 
1 1 
1 1 
1 1 
1 1 
1 1 
1 1 
1 1 
1 1 
1 1 
1 1 
1 1 
1 1 
1 1 
1 1 
1 1 
1 1 
1 1 
...

result:

ok good!

Test #31:

score: -7
Time Limit Exceeded

input:

1
15000
1
1

output:


result:


Subtask #3:

score: 0
Wrong Answer

Test #45:

score: 12
Accepted
time: 3ms
memory: 16084kb

input:

2
7 8
2
1 2

output:

8
2 2 1 
2 2 1 
2 2 1 
2 2 1 
2 2 1 
2 2 1 
2 2 1 
1 2 

result:

ok good!

Test #46:

score: 0
Accepted
time: 2ms
memory: 17500kb

input:

3
5 4 6
2
2 3

output:

6
3 3 1 2 
3 3 1 2 
3 3 1 2 
2 3 1 
2 3 1 
2 3 2 

result:

ok good!

Test #47:

score: 0
Accepted
time: 4ms
memory: 17376kb

input:

3
4 2 9
3
1 2 3

output:

9
2 3 1 
2 3 1 
2 3 1 
2 3 1 
2 3 2 
2 3 2 
1 3 
1 3 
1 3 

result:

ok good!

Test #48:

score: 0
Accepted
time: 4ms
memory: 19568kb

input:

4
3 5 4 3
2
3 4

output:

5
3 2 3 1 
3 2 3 1 
3 2 3 4 
3 2 3 4 
3 2 1 4 

result:

ok good!

Test #49:

score: 0
Accepted
time: 4ms
memory: 19484kb

input:

4
1 4 5 5
3
1 3 4

output:

5
3 3 4 2 
3 3 4 2 
3 3 4 2 
3 3 4 2 
3 3 4 1 

result:

ok good!

Test #50:

score: 0
Accepted
time: 2ms
memory: 21344kb

input:

4
3 3 6 3
3
2 3 4

output:

6
3 3 1 4 
3 3 1 4 
3 3 1 4 
2 3 2 
2 3 2 
2 3 2 

result:

ok good!

Test #51:

score: 0
Accepted
time: 2ms
memory: 20920kb

input:

5
4 3 3 3 1
3
2 4 5

output:

4
4 1 2 3 4 
4 1 2 3 4 
4 1 2 4 5 
2 1 3 

result:

ok good!

Test #52:

score: 0
Accepted
time: 2ms
memory: 21012kb

input:

5
4 3 3 3 2
3
3 4 5

output:

4
4 1 2 3 4 
4 1 2 3 5 
4 1 2 4 5 
3 1 3 4 

result:

ok good!

Test #53:

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

input:

5
4 4 4 2 1
3
2 4 5

output:

5
5 1 2 3 4 5 
4 1 2 3 4 
2 1 2 
2 1 3 
2 2 3 

result:

ok good!

Test #54:

score: 0
Accepted
time: 2ms
memory: 21696kb

input:

5
3 3 3 3 3
3
1 2 4

output:

5
4 1 2 4 5 
4 1 3 4 5 
4 1 3 4 5 
2 2 3 
1 2 

result:

ok good!

Test #55:

score: 0
Accepted
time: 4ms
memory: 22196kb

input:

6
3 3 3 2 2 2
3
2 4 6

output:

-1

result:

ok no solution

Test #56:

score: 0
Accepted
time: 0ms
memory: 21696kb

input:

6
3 3 3 2 2 2
3
2 5 6

output:

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

result:

ok good!

Test #57:

score: 0
Accepted
time: 2ms
memory: 24984kb

input:

6
4 4 3 2 1 1
3
1 3 5

output:

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

result:

ok good!

Test #58:

score: 0
Accepted
time: 0ms
memory: 25444kb

input:

6
7 2 2 2 1 1
5
2 3 4 5 6

output:

7
3 1 2 6 
2 1 2 
2 1 3 
2 1 3 
2 1 4 
2 1 4 
2 1 5 

result:

ok good!

Test #59:

score: 0
Accepted
time: 2ms
memory: 25976kb

input:

7
3 3 3 2 2 1 1
3
1 4 6

output:

4
6 1 2 3 4 6 7 
4 1 2 3 5 
4 1 3 4 5 
1 2 

result:

ok good!

Test #60:

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

input:

7
4 4 3 1 1 1 1
3
1 4 6

output:

6
4 1 2 3 5 
4 1 2 3 6 
4 1 3 4 7 
1 1 
1 2 
1 2 

result:

ok good!

Test #61:

score: 0
Accepted
time: 2ms
memory: 26264kb

input:

8
2 2 2 2 2 2 2 1
6
1 2 3 4 6 7

output:

3
6 1 2 4 5 6 7 
6 1 3 4 6 7 8 
3 2 3 5 

result:

ok good!

Test #62:

score: 0
Accepted
time: 0ms
memory: 25824kb

input:

8
3 3 3 2 1 1 1 1
4
4 6 7 8

output:

3
7 1 2 3 4 6 7 8 
4 1 2 3 4 
4 1 2 3 5 

result:

ok good!

Test #63:

score: -12
Wrong Answer
time: 2ms
memory: 28888kb

input:

8
4 3 3 1 1 1 1 1
4
1 6 7 8

output:

9
7 1 3 4 5 6 7 8 
1 1 
1 1 
1 1 
1 2 
1 2 
1 2 
1 3 
1 3 

result:

wrong answer you used more buckets than jury

Subtask #4:

score: 0
Skipped

Dependency #1:

100%
Accepted

Dependency #3:

0%

Subtask #5:

score: 0
Skipped

Dependency #4:

0%

Subtask #6:

score: 0
Skipped

Dependency #1:

100%
Accepted

Dependency #2:

0%