Блог пользователя Shayan

Автор Shayan, 20 месяцев назад, По-английски

Note: The text editorials will be provided by the authors of the round. This video tutorial acts as an additional resource for those who prefer video over text, and not as a substitute for the text editorial.

2004A — Closest Point

Video

2004B — Game with Doors

Video

2004C — Splitting Items

Video

2004D — Colored Portals

Video

2004E — Not a Nim Problem

Video

2004F — Make a Palindrome

Video
  • Проголосовать: нравится
  • +21
  • Проголосовать: не нравится

»
20 месяцев назад, скрыть # |
 
Проголосовать: нравится +3 Проголосовать: не нравится

BRUUUUHHHHHHH I didn't notice the change in B until after the contest :( such BS

»
20 месяцев назад, скрыть # |
 
Проголосовать: нравится +11 Проголосовать: не нравится

Will a tutorial on problem G appear?

»
20 месяцев назад, скрыть # |
 
Проголосовать: нравится +48 Проголосовать: не нравится

Are there written solutions for the problems? My English listening is poor.

»
20 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

WHERE D hacked ? anyone have test case ?

»
20 месяцев назад, скрыть # |
 
Проголосовать: нравится +18 Проголосовать: не нравится

Is it a tendency, that now we have video editorials instead text one? I don't know, right now, is it better or worse, but definetly text editorials provides faster acsess to solution idea, because reading is faster than watching video. On another hand video edits can be easier to understand, so I personally prefer there both would be

»
20 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Can we solve D using DSU? If not why

»
20 месяцев назад, скрыть # |
 
Проголосовать: нравится +7 Проголосовать: не нравится

i prefer text editorials

»
20 месяцев назад, скрыть # |
 
Проголосовать: нравится +3 Проголосовать: не нравится

where G

»
20 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Yoo everyone, I was trying to upsolve the problems and I submitted the code for problem D and decided to take a break and now when I came back, it's been over 15 mins but my code is still in the queue, idk wht to do

»
20 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Can anyone tell me why the first code is getting AC but the second one got hacked and now is showing TLE? Same logic. But in first one im passing from left to right and in second one im passing from right to left.

Thanks!

Code 1

	public static void solve() {
		int n = ii(), k = ii();
		List<Integer> A = new ArrayList<>();
		for(int i = 0; i < n; ++i) {
			A.add(ii());
		}
		Collections.sort(A, (a , b) -> Integer.compare(b, a));
		for(int i = 0; i < n - 1; i += 2) {
			int d = A.get(i) - A.get(i + 1);
			int min = Math.min(k, d);
			A.set(i + 1, A.get(i + 1) + min);
			k -= min;
		}
		long alice = 0, bob = 0;
		for(int i = 0; i < n; ++i) {
			if(i % 2 == 0) alice += A.get(i);
			if(i % 2 != 0) bob += A.get(i);
		}
		System.out.println(alice - bob);
	}

Code 2

	public static void solve() {
		int n = ii(), k = ii();
		int [] A = iir(n);
		Arrays.sort(A);
		for(int i = n - 2; i >= 0; i -= 2) {
			int d = A[i + 1] - A[i];
			int min = Math.min(k, d);
			A[i] += min;
			k -= min;
		}
		long x = 0, alice = 0, bob = 0;
		for(int i = n - 1; i >= 0; --i) {
			if(x % 2 == 0) alice += A[i];
			if(x++ % 2 != 0) bob += A[i];
		}
		System.out.println(alice - bob);
	}