# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
530163 |
2022-02-24T17:58:36 Z |
FelipeH |
Teams (CEOI11_tea) |
C++14 |
|
2500 ms |
36176 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(j);
}
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 |
13 ms |
23700 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
12 ms |
23752 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
14 ms |
23756 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
21 ms |
23800 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
21 ms |
23756 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
833 ms |
25300 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1032 ms |
25520 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
2586 ms |
32820 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
2584 ms |
35840 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
2575 ms |
36176 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |