Wrong Answer
Code
#include <bits/stdc++.h>
using namespace std;
int part(int n) {
for (int length = 2; length <= n / 2; ++length) {
if (n % length != 0) {
continue;
}
bool is_possible = true;
for (int i = 0; i < n; i += length) {
int max_element = i + length;
int min_element = i + 1;
for (int j = i + 1; j < i + length; ++j) {
if (max_element < n && max_element < j + 1) {
max_element = j + 1;
}
if (min_element < n && min_element > j + 1) {
min_element = j + 1;
}
}
if (abs(max_element - min_element) != 1) {
is_possible = false;
break;
}
}
if (is_possible) {
return n / length;
}
}
return 1;
}
int main() {
int T;
cin >> T;
while (T--) {
int n;
cin >> n;
cout << part(n) << endl;
}
return 0;
}
Information
- Submit By
- Type
- Submission
- Problem
- P1052 Yet Another Array Partition
- Contest
- Brain Booster #3
- Language
- C++20 (G++ 13.2.0)
- Submit At
- 2024-05-06 17:19:47
- Judged At
- 2024-11-11 03:32:18
- Judged By
- Score
- 10
- Total Time
- 6ms
- Peak Memory
- 536.0 KiB