Submission #875420

#TimeUsernameProblemLanguageResultExecution timeMemory
875420ElenaBMTeams (CEOI11_tea)C++17
0 / 100
415 ms26176 KiB
#include <bits/stdc++.h> using namespace std; int main() { int n; cin>> n; vector<int>a; vector<pair<int,int>>v(n); for (int i = 0; i < n; ++i){ int x; cin>> x; v[i] = {x, i+1}; } sort(v.begin(), v.end()); int num = 0, ans = 0; int i = n-1; while(i >= 0){ if (i - v[i].first >= 0){ int aux = i; i -= (v[i].first-1); ans++; if (i - (v[i].first-1) < 0){ //cout<< i - (v[i].first-1)<< '\n'; a.push_back(aux+1); } else a.push_back(v[aux].first); } else break; } cout<< ans << '\n'; i = n-1; for (int j = 0; j < (int) a.size(); ++j){ cout<< a[j]<< ' '; while(a[j]){ cout<< v[i].second<< ' '; i--; a[j]--; } cout<< '\n'; } return 0; }

Compilation message (stderr)

tea.cpp: In function 'int main()':
tea.cpp:17:9: warning: unused variable 'num' [-Wunused-variable]
   17 |     int num = 0, ans = 0;
      |         ^~~
#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...