Submission #530138

# Submission time Handle Problem Language Result Execution time Memory
530138 2022-02-24T17:04:22 Z peuch Teams (CEOI11_tea) C++17
80 / 100
598 ms 119812 KB
#include<bits/stdc++.h>
using namespace std;

const int MAXN = 1e6 + 10;

int n;
pair<int, int> v[MAXN];

vector<vector<int> > group;
set<pair<int, int> > tam;

int main(){
  scanf("%d", &n);
  for(int i = 1; i <= n; i++){
    scanf("%d", &v[i].first);
    v[i].second = i;
  }
  sort(v + 1, v + 1 + n);
  reverse(v + 1, v + 1 + n);
  for(int i = 1; i <= n; i++){
    int cur = v[i].second;
    int qnt = v[i].first;
    if(qnt > n - i + 1){
      int grp = tam.begin()->second;
      tam.erase(tam.begin());
      group[grp].push_back(cur);
      tam.insert(make_pair(group[grp].size(), grp));
      continue;
    }
    group.push_back(vector<int> (1, cur));
    int idx = group.size() - 1;
    while(--qnt)
      group[idx].push_back(v[++i].second);
    tam.insert(make_pair(group[idx].size(), idx));
  }
  printf("%lu\n", group.size());
  for(int i = 0; i < group.size(); i++){
    printf("%lu ", group[i].size());
    sort(group[i].begin(), group[i].end());
    for(int j = 0; j < group[i].size(); j++)
      printf("%d ", group[i][j]);
    printf("\n");
  }
}

Compilation message

tea.cpp: In function 'int main()':
tea.cpp:37:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   37 |   for(int i = 0; i < group.size(); i++){
      |                  ~~^~~~~~~~~~~~~~
tea.cpp:40:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   40 |     for(int j = 0; j < group[i].size(); j++)
      |                    ~~^~~~~~~~~~~~~~~~~
tea.cpp:13:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |   scanf("%d", &n);
      |   ~~~~~^~~~~~~~~~
tea.cpp:15:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   15 |     scanf("%d", &v[i].first);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
# 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 380 KB Output is correct
2 Correct 2 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 25 ms 1812 KB Output is correct
2 Correct 20 ms 1948 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 27 ms 1920 KB Output is correct
2 Correct 20 ms 2124 KB Output is correct
3 Correct 28 ms 1896 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 224 ms 14788 KB Output is correct
2 Correct 195 ms 17212 KB Output is correct
3 Correct 223 ms 15432 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 306 ms 19092 KB Output is correct
2 Correct 598 ms 119812 KB Output is correct
3 Correct 307 ms 22440 KB Output is correct
4 Correct 289 ms 17072 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 349 ms 18960 KB Output is correct
2 Correct 216 ms 19036 KB Output is correct
3 Correct 272 ms 19848 KB Output is correct
4 Correct 334 ms 19160 KB Output is correct