QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#750128#7866. TeleportationcaiwenWA 1ms4196kbC++141.2kb2024-11-15 12:51:312024-11-15 12:51:31

Judging History

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

  • [2024-11-15 12:51:31]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:4196kb
  • [2024-11-15 12:51:31]
  • 提交

answer

//Powered by COJ
//cfe91ea0-8baf-4a31-a36f-e5da7dd1fdd1


#include<bits/stdc++.h>
using namespace std;
const int N = 100005;
int a[N],f[N];

//namespace SegTree{
//	#define l(p) t[(p)].l
//	#define r(p) t[(p)].r
//	#define sum(p) t[(p)].sum
//	#define lc(p) ((p) << 1)
//	#define rc(p) ((p) << 1 | 1)
//	struct node{
//		int l;
//		int r;
//		int sum;
//	}t[N << 2];
//	
//	inline void build(int p,int l,int r){
//		l(p) = l,r(p) = r;
//		if(l == r){
//			sum(p) = INF;
//			return;
//		}
//		int mid = (l + r) >> 1;
//		build(lc(p),l,mid);
//		build(rc(p),mid + 1,r);
//		push_up(p);
//	}
//	
//	inline void change(int p,int l,int r,int d){
//		int 
//	}
//}

int main(){
	int n,m;
	cin>>n>>m;
	m ++;
	memset(f,0x3f,sizeof(f));
	f[1] = 0;
	priority_queue<pair<int,int> > q;
	priority_queue<int> h;
	for(int i = 1;i <= n;++ i){
		cin>>a[i];
		a[i + n] = a[i];
	}
	q.push({-(1 + a[1]),f[1] - 1 - a[1]});
	for(int i = 2;i <= n * 2;++ i){
		while(!q.empty() && -q.top().first <= i){
			h.push(-q.top().second);
			q.pop();
		}
		if(!h.empty()){
			f[i] = i - h.top() + 1;
//			cout<<"now top = "<<h.top()<<"\n";
			q.push({-(i + a[i]),f[i] - i - a[i]});
		}
	}
//	for(int i = 1;i <= m;++ i) cout<<f[i]<<" ";
	cout<<min(f[m],f[m + n]);
	return 0;
}


详细

Test #1:

score: 100
Accepted
time: 0ms
memory: 4196kb

input:

4 3
0 1 2 3

output:

4

result:

ok 1 number(s): "4"

Test #2:

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

input:

4 3
0 0 0 0

output:

4

result:

ok 1 number(s): "4"

Test #3:

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

input:

4 3
2 2 2 2

output:

2

result:

ok 1 number(s): "2"

Test #4:

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

input:

2 1
0 0

output:

2

result:

ok 1 number(s): "2"

Test #5:

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

input:

2 1
1 1

output:

1

result:

ok 1 number(s): "1"

Test #6:

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

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'