QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#694139#5417. Chat ProgramYuanyin26WA 21ms5268kbC++201.4kb2024-10-31 17:20:242024-10-31 17:20:27

Judging History

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

  • [2024-10-31 17:20:27]
  • 评测
  • 测评结果:WA
  • 用时:21ms
  • 内存:5268kb
  • [2024-10-31 17:20:24]
  • 提交

answer

#include<iostream>
#include<vector>
#include<cstring>
#include<algorithm>
#include<cstdio>
#include<queue>
#include<string.h>
#include <string>
#include<math.h>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<map>
#include<queue>
#include<stack>
#include<functional>
#include<deque>
using namespace std;

#define MAXN 301000;
#define ll long long
#define lll unsigned long long
#define PA pair<ll,ll>
#define INF (ll)0x3f3f3f3f*(ll)1000000
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int N = 2e5 + 7;
const ll mod = 1e9 + 7;
int n, k, m, c,d;
int a[N];
bool check(int x)
{
	vector<int>cf(n + 2, 0);
	for (int i = 1; i <= n; i++)
	{
		if (a[i] >= x)cf[1]++;
		else if (a[i] + c + min(i-1,(m - 1)) * d < x);
		else 
		{
			int in;
			if (d == 0)
			{
				in = 0;
			}
			else 
				in = ((x - a[i] - c)+(d-1)) / d;
			int l = i - m + 1 >= 0 ? i - m + 1 : 1, r = i - in  >= 0 ? i - in  : 1;
			cf[l]++, cf[r + 1]--;
		}
	}
	for (int i = 1; i <= n; i++)
	{
		cf[i] = cf[i - 1] + cf[i];
		if (cf[i] >= k)return true;
	}
	return false;
}
void solve()
{
	cin >> n >> k >> m >> c >> d;
	for (int i = 1; i <= n; i++)
		cin >> a[i];
	int l = -1, r = 2e5 + 1;
	while (l + 1 != r)
	{
		int mid = (l + r) >> 1;
		if (check(mid))l = mid;
		else r = mid;
	}
	cout << l << endl;
}
int main() {
	IOS;
	int t = 1;// cin >> t;
	while (t--) {
		solve();
	}
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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: 3588kb

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: 3708kb

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: 14ms
memory: 5188kb

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: 21ms
memory: 5268kb

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:

200000

result:

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