Submission #530165

#TimeUsernameProblemLanguageResultExecution timeMemory
530165FelipeHTeams (CEOI11_tea)C++14
0 / 100
2587 ms36172 KiB
#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(t[j].size() + 1 < v[i].first) continue; if(smallest == 0 || t[smallest].size() > t[j].size()){ 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 (stderr)

tea.cpp: In function 'int main()':
tea.cpp:39:26: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   39 |       if(t[j].size() + 1 < v[i].first) continue;
      |          ~~~~~~~~~~~~~~~~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...