QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#323262#7627. PhonyBrotherCallWA 1ms3628kbC++141.5kb2024-02-09 03:03:272024-02-09 03:03:27

Judging History

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

  • [2024-02-09 03:03:27]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3628kb
  • [2024-02-09 03:03:27]
  • 提交

answer

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
using namespace std;

const int N = 1e6 + 100;
int n , m , k;
int a[N] , b[N] , c[N];
vector<int> v;

bool compare(int s1 ,int s2) {
	return s1 > s2;
}

int main() {
	cin >> n >> m >> k;
	for(int i = 1;i <= n;i ++)
		cin >> a[i];
	sort(a + 1 , a + 1 + n , compare);
	for(int i = 1;i < n;i ++) {
		int del = a[i] / k - a[i + 1] / k;
		c[i] = a[i] / k * k;
		b[i] = b[i - 1] + i * del;
	}
	int cnt = 0 , hand = 1 , lst;
	v.push_back(a[1] % k);
	while(cnt >= b[hand] && hand < n) {
		auto it = upper_bound(v.begin() , v.end() , a[hand + 1] % k);
		v.insert(it , a[hand + 1] % k);
		hand ++;
	}
	for(int i = 1;i <= m;i ++) {
		char ch;int x;
		cin >> ch >> x;
		if(ch == 'A') {
			if(x <= hand) {
				int nb = cnt - b[hand - 1];
				int st = c[hand] - nb / hand * k;
				int kk = nb % hand;if(kk == 0) kk = hand;
				if(x <= kk) {
					int now = (kk + x) % hand;
					if(now == 0) now = hand;
					int nxt = v[hand - now];
					cout << st + nxt << endl;
				}
					else {
						int now = (kk + x) % hand;
						if(now == 0) now = hand;
						int nxt = v[hand - now];
						cout << st + nxt - k << endl;
					}
			} else {
				cout << a[x] << endl;
			}
		} else {
			cnt += x;
			while(cnt >= b[hand] && hand < n) {
				auto it = upper_bound(v.begin() , v.end() , a[hand + 1] % k);
				v.insert(it , a[hand + 1] % k);
				hand ++;
			}
		}
	}
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3628kb

input:

3 5 5
7 3 9
A 3
C 1
A 2
C 2
A 3

output:

3
4
-1

result:

ok 3 lines

Test #2:

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

input:

5 8 8
294 928 293 392 719
A 4
C 200
A 5
C 10
A 2
C 120
A 1
A 3

output:

294
-88
-89
-288
-282

result:

wrong answer 2nd lines differ - expected: '200', found: '-88'