QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#769144#7866. TeleportationWilliamHuWA 1ms5776kbC++17827b2024-11-21 16:19:002024-11-21 16:19:02

Judging History

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

  • [2024-11-21 16:19:02]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:5776kb
  • [2024-11-21 16:19:00]
  • 提交

answer

#include<bits/stdc++.h>
#define int long long
using namespace std;
int read()
{
	int x = 0, f = 1;
	char c = getchar();
	while(c != EOF and !isdigit(c))
	{
		if(c == '-')f = -1;
		c = getchar();
	}
	while(isdigit(c))
	{
		x = x * 10 + c - '0';
		c = getchar();
	}
	return x * f;
}
int n, k, a[1000010], f[1000010];
signed main()
{
	int T = 1;
	while(T --)
	{
		n = read();
		k = read();
		for(int i = 0;i <= 3 * n;i ++)f[i] = 0x3f3f3f3f3f3f3f3f;
		f[0] = 0;
		for(int i = 0;i< n;i ++)a[i] = a[i + n] = a[i + 2*n] = read();
		for(int i = 0;i < 3*n;i ++)
		{
			for(int j = 0;a[i]+i+j < 3*n;j ++)
			{
				//if(f[j] < f[i] + (j - i - a[i] + 1))break;
				f[a[i]+i+j] = min(f[a[i]+i+j], f[i] + j+1);
			}
			//cout<<f[i]<<endl;
		}
		cout<<min(f[k], f[k+n])<<'\n';
		
	}
	return 0;
}


Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

4 3
0 1 2 3

output:

4

result:

ok 1 number(s): "4"

Test #2:

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

input:

4 3
0 0 0 0

output:

4

result:

ok 1 number(s): "4"

Test #3:

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

input:

4 3
2 2 2 2

output:

2

result:

ok 1 number(s): "2"

Test #4:

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

input:

2 1
0 0

output:

2

result:

ok 1 number(s): "2"

Test #5:

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

input:

2 1
1 1

output:

1

result:

ok 1 number(s): "1"

Test #6:

score: -100
Wrong Answer
time: 1ms
memory: 5628kb

input:

300 25
182 9 13 211 258 132 27 42 218 200 271 258 164 121 8 84 29 195 141 290 110 0 272 93 142 134 140 32 232 99 162 199 297 287 212 29 182 53 61 98 116 282 75 245 230 165 22 4 179 89 274 231 46 299 248 208 200 285 221 50 221 199 294 241 195 138 22 204 113 100 132 276 158 146 238 178 100 94 131 157 ...

output:

13

result:

wrong answer 1st numbers differ - expected: '10', found: '13'