QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#251814#7695. Double Upmendicillin2#WA 1ms3700kbC++171.1kb2023-11-15 09:42:462023-11-15 09:42:46

Judging History

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

  • [2023-11-15 09:42:46]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3700kb
  • [2023-11-15 09:42:46]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

template <typename T> inline void read(T &n) {
	T w = 1; n = 0; char ch = getchar();
	while (!isdigit(ch) && ch != EOF) { if (ch == '-') w = -1; ch = getchar(); }
	while (isdigit(ch) && ch != EOF) { n = (n << 3) + (n << 1) + (ch & 15); ch = getchar(); }
	n *= w;
}

template <typename T> inline void write(T x) {
	T l = 0, y = 0;
	if (!x) { putchar(48); return; }
	while (x) { y = y * 10 + x % 10; x /= 10; ++l; }
	while (l) { putchar(y % 10 + 48); y /= 10; --l; }
}

const int N = 1010;

__int128 a[N];

int main() {
	int n; read(n);
	for (int i = 1; i <= n; ++i) read(a[i]);
	__int128 now = 1, ans = 0;
	int mx = n;
	for (int id = 0; id <= 100; ++id) {
		for (int i = 1; i <= mx; ++i)
			if (a[i] == now && a[i + 1] == now) {
				a[i] += a[i + 1];
				ans = max(ans, a[i]);
				a[i + 1] = 0;
			}
		for (int i = mx; i >= 1; --i) {
			if (a[i] == now) ans = max(ans, a[i]);
			if (a[i] == now || a[i] == 0) {
				for (int j = i; j <= mx; ++j) a[j] = a[j + 1];
				--mx;
			}
		}
		now *= 2;
	}
	write(ans);
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3536kb

input:

5
4 2 2 1 8

output:

16

result:

ok single line: '16'

Test #2:

score: 0
Accepted
time: 1ms
memory: 3572kb

input:

1000
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1...

output:

512

result:

ok single line: '512'

Test #3:

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

input:

1000
1267650600228229401496703205376 1267650600228229401496703205376 1267650600228229401496703205376 1267650600228229401496703205376 1267650600228229401496703205376 1267650600228229401496703205376 1267650600228229401496703205376 1267650600228229401496703205376 1267650600228229401496703205376 1267650...

output:

2535301200456458802993406410752

result:

wrong answer 1st lines differ - expected: '649037107316853453566312041152512', found: '2535301200456458802993406410752'