QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#695683#5417. Chat ProgramyaLenWA 6ms5904kbC++142.1kb2024-10-31 20:35:182024-10-31 20:35:18

Judging History

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

  • [2024-10-31 20:35:18]
  • 评测
  • 测评结果:WA
  • 用时:6ms
  • 内存:5904kb
  • [2024-10-31 20:35:18]
  • 提交

answer

#include <bits/stdc++.h>
#define KE ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
using namespace std;
#define int long long
#define flt(x) cout << fixed << setprecision(x);
#define all(x) (x).begin(), (x).end()
#define bcount(t) __builtin_popcount(t)
#define Mod(x,m) (((x) % m + m) % m)
#define flip(x) reverse(x)
#define lowbit(x) (x&(-x))
#define bemax(x,y) x = max(x, y)
#define pb push_back
#define elif else if
#define endl '\n'
#define AA cerr << "AA" << endl;
#define  __ << " " <<

const int N = 1e5 + 10;
const int inf = 1e18;
const int mod = 1e9 + 7;
typedef pair<int, int> pii;

int n,k,m,c,d;
int a[N];
int tag[N];
int f[N];
int maxn;
bool check(int x){
	memset(tag,0,sizeof tag);
	int res=0;
	for(int i=1;i<=n;i++){
		if(a[i]>=x){
			res++;
			tag[i]=1;
			if(res>=k)return true;//涓€瀹氬姞涓婏紝鍥犱负涓€寮€濮媘id寰堝ぇ锛屾暟鎹繃澶氱殑鎯呭喌涓嬩笉鍙婃椂return浼氳秴鏃?
		}
	}
	memset(f,0,sizeof f);
	for(int i=1;i<=n;i++){
		if(!tag[i]){
			int r=min(m-1,i-1);
			if(a[i]+d*r+c<x)continue;//濡傛灉鏈€澶х殑涔熷皬浜庨偅灏变笉鐢ㄨ€冭檻浜?
			else {
				f[max(i,m)]++;//棣栧厛瀹冧細瀵瑰綋鍓嶈繖涓綅缃骇鐢?1鐨勫奖鍝?
				if(a[i]+c>=x)f[min(n,i+m)]--;//濡傛灉鏈€灏忕殑鍔犱笂涔熷ぇ浜巟锛岄偅涔堝氨鏄畠绂诲紑鎺у埗鑼冨洿鐨勬椂鍊?-
				else{
			       long long t = x- a[i] - c;
                   int pos;
                   if (t % d == 0) pos = t / d - 1;
                   else pos = t / d;
                   f[min(n + 1, i + m - pos - 1)]--;
				}
			}
		}
	}
	for(int i=m;i<=n+1;i++){
		if(res>=k)return true;//璁$畻鏈€闀垮墠缂€鍜?
		res+=f[i];
	}
	return false;
}
void solve(){
	cin>>n>>k>>m>>c>>d;
	for(int i=1;i<=n;i++){
		cin>>a[i];
	}
	int ll=0,rr=1e18;
	maxn=c+(m-1)*d;
	while(ll<rr){
		int mid=(ll+rr+1)/2;
		if(check(mid))
		{
		   ll=mid;
		}
		else rr=mid-1;
	}
	cout<<ll<<endl;
}

signed main(){
	KE;
	int T = 1;
//	cin >> T;
//  flt(3);
	while(T--){
		solve();
	}
	return 0;
}


详细

Test #1:

score: 100
Accepted
time: 4ms
memory: 5852kb

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: 4ms
memory: 5216kb

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

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: -100
Wrong Answer
time: 6ms
memory: 5904kb

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:

1000000000000000000

result:

wrong answer 1st numbers differ - expected: '0', found: '1000000000000000000'