Comments

MikeMirzayanov At least unordered-containers could be added. We really need HashMap. See 83564736 for an example.

we are restoring back the total difference, tdiff.

On Barichek → Codeforces Round #407, 10 years ago
-29

fail 4 times, which case did I missed?

P231C is possible in O(n) using two pointers. First Input n,k,array (a). Sort array a.

int n = in.nextInt(), k = in.nextInt();
int[] a = new int[n];
for (int i = 0; i < n; i++) {
	a[i] = in.nextInt();
}
Arrays.sort(a);
int i = n - 1, j = n - 2;
int mocc = 0;
int mnum = 0;
int num = a[n - 1];
int tdiff = 0;
int occ = 1;
while (i >= 0 && j >= 0) {//0 2 3 4 6
	if (tdiff + num - a[j] <= k) {
		tdiff += num - a[j];
		occ++;
		j--;
	} else {
		if (occ >= mocc) {
			mocc = occ;
			mnum = num;
		}
		occ--;
		tdiff += (i - j - 1) * (a[i - 1] - a[i]);
		num = a[--i];
	}
}
if (occ >= mocc) {
	mocc = occ;
	mnum = num;
}

You need mocc and mnum.

On Lewin → Codeforces Round #385 Editorial, 10 years ago
-24

Too bad I solved Div2D but I did not count properly the number of indexes which I was asking as a question.

In problem C, I did made a cnt array (or say a hashmap) and did find all primes below the maximum x using Sieve of Erathosthenes, then for each prime I iterated over every number and and found f(p) and stored them in a Binary Index Tree, but that didn't help. I believe my complexity is O(n(logn)(loglogn)+m(logn+logP)+PlogP) where P(664,579~10^7) is the count of primes below maximum x so total operations are around 5e6+6e7+4e7 but it has a TLE?.This is my submission.

Very Nice Question A

Thanks for the counterexample in Div2C.

Why the site is not working? It is down and when it will be working?

On adityagupta1089 → Can't See My Codes, 10 years ago
0

I think this is with problems that are <100 as @Seiche said, also all of which are maybe CodeForces beta round problems. Maybe beta rounds didn't had this functionality earlier?

0

I don't get it, why does it works?

+2

Editorial -> when? please. Thnakyou.

oh great thanks.

-10

Perfectly right submission http://codeforces.me/contest/677/submission/18209483 calculating 3^n. WTF test 9 has no input. I was lied. they said length was more than 1? In contest solved two problems but shouldve used long for t in 2B but i used int for a perfectly correct answer :(