QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#678729#5417. Chat ProgramyimgWA 44ms6268kbC++201.1kb2024-10-26 15:54:542024-10-26 15:54:54

Judging History

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

  • [2024-10-26 15:54:54]
  • 评测
  • 测评结果:WA
  • 用时:44ms
  • 内存:6268kb
  • [2024-10-26 15:54:54]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;

using i64 = long long;

void work()
{
	i64 n, k, m, c, d;
	cin >> n >> k >> m >> c >> d;
	vector<i64> a(n + 1);
	for(int i = 1; i <= n; ++i){
		cin >> a[i];
	}
	i64 l = 0, r = 1e18;
	auto check = [&](i64 x){
//		cout << "fds";
//		return 1;
		vector<i64> s(n + 5);
		for(int i = 1; i <= n; ++i){
			if(a[i] >= x) s[1]++;
			else{
				i64 lbd = max(1LL, i - m + 1);
				
				i64 rbd = 0;
				if(a[i] + c + (m - 1) * d >= x) {
					lbd = max(1LL, i - m + 1);
					if(d) rbd = min(i * 1LL, i - (x - c - a[i] + d - 1) / d - 1);
					else if(c) rbd = i;
//					cout << " LLL : " << lbd << " " << rbd << "\n";
					if(lbd <= rbd) s[lbd]++, s[rbd + 1]--;
				}	
			}
		}
//		for(int i = 1; i <= n; ++i) cout << s[i] << "\n";
		for(int i = 1; i <= n; ++i){
			s[i] += s[i - 1];
			if(s[i] >= k) return 1;
		}
		return 0;
	};
	while(l < r){
		i64 m = (l + r + 1) >> 1;
		if(check(m)) l = m;
		else r = m - 1;	
	}
//	check(9);
	cout << l << "\n";
} 

 
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t = 1;
//	cin >> t;
	while(t--)
		work();
}

詳細信息

Test #1:

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

input:

6 4 3 1 2
1 1 4 5 1 4

output:

4

result:

ok 1 number(s): "4"

Test #2:

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

input:

7 3 2 4 0
1 9 1 9 8 1 0

output:

9

result:

ok 1 number(s): "9"

Test #3:

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

input:

8 3 5 0 0
2 0 2 2 1 2 1 8

output:

2

result:

ok 1 number(s): "2"

Test #4:

score: 0
Accepted
time: 44ms
memory: 6268kb

input:

200000 200000 100000 0 1000000000
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...

output:

0

result:

ok 1 number(s): "0"

Test #5:

score: -100
Wrong Answer
time: 43ms
memory: 6268kb

input:

200000 1 100000 1000000000 1000000000
1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 100000000...

output:

100000000000000

result:

wrong answer 1st numbers differ - expected: '100001000000000', found: '100000000000000'