QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#694221#5417. Chat ProgramYuanyin26Compile Error//C++201.4kb2024-10-31 17:30:082024-10-31 17:30:09

Judging History

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

  • [2024-10-31 17:30:09]
  • 评测
  • [2024-10-31 17:30:08]
  • 提交

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 int 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 int 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 = 1e19;
	while (l + 1 != r)
	{
		int mid = (l + r) >> 1;
		if (check(mid))l = mid;
		else r = mid;
	}
	cout << l << endl;
}
unsigned main() {
	IOS;
	int t = 1;// cin >> t;
	while (t--) {
		solve();
	}
}

详细

answer.code: In function ‘void solve()’:
answer.code:66:25: warning: overflow in conversion from ‘double’ to ‘long long int’ changes value from ‘1.0e+19’ to ‘9223372036854775807’ [-Woverflow]
   66 |         int l = -1, r = 1e19;
      |                         ^~~~
At global scope:
cc1plus: error: ‘::main’ must return ‘int’