Submission #530162

# Submission time Handle Problem Language Result Execution time Memory
530162 2022-02-24T17:56:44 Z LFFB Teams (CEOI11_tea) C++14
0 / 100
263 ms 20968 KB
#include <iostream>
#include <vector>
#include <algorithm>

const int MAX_N = 1000000 + 10;

int n;
std::pair<int, int> input[MAX_N];

bool sortingFunction(std::pair<int, int> a, std::pair<int, int> b) {
    return a.first > b.first;
}

int main() {

    scanf("%d", &n);

    for (int i = 0; i < n; i++) {
        int x;
        scanf("%d", &x);
        input[i] = std::make_pair(x, i);
    }

    std::sort(input, input + n, sortingFunction);

    std::vector<int> teamSize;
    std::vector<std::vector<int>> team;
    std::vector<int> minimum;
    int index = 0;
    int remaining = n;

    teamSize.push_back(1);
    team.push_back(std::vector<int>());
    team[0].push_back(input[0].second);
    minimum.push_back(input[0].first);

    for (int i = 1; i < n; i++) {
        remaining--;
        if (minimum[index] > teamSize[index]) {
            teamSize[index]++;
            team[index].push_back(input[i].second);
        } else if (remaining >= input[i].first) {
            teamSize.push_back(1);
            team.push_back(std::vector<int>());
            minimum.push_back(input[i].first);
            index++;
            team[index].push_back(input[i].second);
        } else {
            teamSize[index]++;
            team[index].push_back(input[i].second);
        }
    }

    printf("%d\n", (int)team.size());

    for (std::vector<int> t : team) {
        printf("%d ", (int)t.size());
        for (int x : t) printf("%d ", x + 1);
        printf("\n");
    }

}

Compilation message

tea.cpp: In function 'int main()':
tea.cpp:17:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   17 |     scanf("%d", &n);
      |     ~~~~~^~~~~~~~~~
tea.cpp:21:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   21 |         scanf("%d", &x);
      |         ~~~~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Incorrect 0 ms 204 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 332 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 332 KB Output is correct
2 Incorrect 2 ms 332 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 20 ms 1820 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 22 ms 1996 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 208 ms 14880 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 252 ms 19328 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 263 ms 20968 KB Output isn't correct
2 Halted 0 ms 0 KB -