Submission #530164

# Submission time Handle Problem Language Result Execution time Memory
530164 2022-02-24T18:02:30 Z FelipeH Teams (CEOI11_tea) C++14
0 / 100
2500 ms 36392 KB
#include<bits/stdc++.h>
using namespace std;

const int MAXN = 1000000 + 10;
pair<int,int> v[MAXN];
vector<int> t[MAXN];

int main(){
  int n; cin >> n;
  for(int i = 1;i<=n;i++){
    int val; cin >> val;
    v[i] = make_pair(val, i);
  }
  sort(v + 1, v + n);
  int ans = 0;
  for(int i = 1;i<=n;i++){
    int cur = i, have = 1;
    int canForm = false;
    while(cur <= n){
      if(v[cur].first > have){
        int diff = v[cur].first - have;
        // printf("difference of %d from %d to desired %d\n",cur,have,v[cur].first);
        have = v[cur].first;
        cur += diff;
      }else{
        // printf("forming a team from %d to %d with %d members\n",i,cur,have);
        ans++;
        for(int j = i;j<=cur;j++){
          t[i].push_back(v[j].second);
        }
        i = cur;
        canForm = true;
        break;
      }
    }
    if(canForm) continue;
    int smallest = 0;
    for(int j = 1;j<i;j++){
      if(smallest == 0 || (t[smallest].size() > t[j].size() && t[j].size() >= v[i].first)){
        smallest = j;
      }
    }
    // printf("inserting %d to team %d\n", i, smallest);
    t[smallest].push_back(v[i].second);
  }
  cout << ans << "\n";
  for(int i = 1;i<=n;i++){
    int size = t[i].size();
    if(size != 0){
      cout << size << " ";
      for(int j = 0;j<size;j++){
        cout << t[i][j] << " ";
      }
      cout << "\n";
    }
  }
  return 0;
}

Compilation message

tea.cpp: In function 'int main()':
tea.cpp:39:76: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   39 |       if(smallest == 0 || (t[smallest].size() > t[j].size() && t[j].size() >= v[i].first)){
      |                                                                ~~~~~~~~~~~~^~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 12 ms 23756 KB Output is correct
2 Incorrect 12 ms 23756 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 12 ms 23724 KB Output is correct
2 Incorrect 14 ms 23688 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 12 ms 23756 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 21 ms 23856 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 22 ms 23852 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1051 ms 25196 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1247 ms 25404 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2559 ms 32916 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2591 ms 35796 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2594 ms 36392 KB Time limit exceeded
2 Halted 0 ms 0 KB -