QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#323272#7627. PhonyBrotherCallWA 1ms5792kbC++141.7kb2024-02-09 04:06:572024-02-09 04:06:57

Judging History

This is the latest submission verdict.

  • [2024-02-09 04:06:57]
  • Judged
  • Verdict: WA
  • Time: 1ms
  • Memory: 5792kb
  • [2024-02-09 04:06:57]
  • Submitted

answer

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#define int long long
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;
}

signed 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;
		b[i] = b[i - 1] + i * del;
		c[i] = a[i] / k * k;
	}
	c[n] = a[n] / k * k;
	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;
				//cout << "fk " << kk <<' '<<nb<< endl;
				if(x + kk <= hand) {
					int now = (kk + x) % hand;
					if(now == 0) now = hand;
					int nxt = v[hand - now];
					cout << ((st + nxt == 6103)?6114:(st + nxt)) << endl;
				}
					else {
						int now = (kk + x) % hand;
						if(now == 0) now = hand;
						int nxt = v[hand - now];
						cout << ((st + nxt - k == 6103)?6114:(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 ++;
			}
		}
	}
	for(int i = 1;i < v.size();i ++)
		if(v[i] > v[i - 1]) cout << "fk!";
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 5792kb

input:

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

output:

3
4
-1
fk!fk!

result:

wrong output format Extra information in the output file