/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Accepted 2ms 484.0 KiB
#2 Wrong Answer 2ms 536.0 KiB
#3 Accepted 2ms 532.0 KiB
#4 Wrong Answer 6ms 324.0 KiB

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