QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#138498#4364. Ceiling FunctionPetroTarnavskyi#WA 10ms5632kbC++171.5kb2023-08-11 20:29:352023-08-11 20:29:36

Judging History

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

  • [2023-08-11 20:29:36]
  • 评测
  • 测评结果:WA
  • 用时:10ms
  • 内存:5632kb
  • [2023-08-11 20:29:35]
  • 提交

answer

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

#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define FOR(i, a, b) for (int i = (a); i<(b); ++i)
#define RFOR(i, b, a) for (int i = (b)-1; i>=(a); --i)
#define MP make_pair
#define PB push_back
#define F first
#define S second
#define FILL(a, b) memset(a, b, sizeof(a))

typedef long long LL;
typedef pair<int, int> PII;
typedef vector<int> VI;

const int MAX = 102;

bool dp[MAX][MAX][MAX][2];

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	vector<int> a(n);
	for (int& ai : a) {
		cin >> ai;
	}
	RFOR(k, MAX, 1) {
		FILL(dp, 0);
		dp[0][a[0]][k][0] = true;
		bool ans = false;
		FOR(i, 0, n) {
			RFOR(j, a[i] + 1, 0) {
				FOR(lev, 0, k + 1) {
					FOR(was0, 0, 2) {
						if (!dp[i][j][lev][was0]) {
							continue;
						}
						if (j == 0) {
							if (i == n - 1) {
								ans |= lev == k && was0 == 1;
							}
							else {
								dp[i + 1][a[i + 1]][lev][was0] = true;
							}
						}
						else {
							if (lev > 0 && j - lev >= 0 && (lev < k || (i == 0 && j == a[0]))) {
								dp[i][j - lev][lev - 1][was0 || (lev == 1)] = true;
							}
							if (j - (lev + 1) >= 0 && (lev + 1 < k || (lev + 1 == k && i == n - 1 && j == k))) {
								dp[i][j - (lev + 1)][lev + 1][was0] = true;
							}
						}
					}
				}
			}
		}
		if (ans) {
			cout << k << "\n";
			return 0;
		}
	}
	cout << "no quotation\n";
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 10ms
memory: 5632kb

input:

5 3
2 7 1
3 1 4
1 5 9
2 6 5
9 7 3

output:

2

result:

wrong answer 1st lines differ - expected: '4', found: '2'