Submission #345341

#TimeUsernameProblemLanguageResultExecution timeMemory
345341koketsuGift (IZhO18_nicegift)C++14
30 / 100
2073 ms212792 KiB
#include <bits/stdc++.h> #define pb push_back #define LL long long #define Kultivator ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); using namespace std; const LL Mxn = 1e6 + 7; const LL Mod = 1e9 + 7; const LL Inf = 1e14 + 7; LL N, A, K, Dum; vector <vector <pair <int, int>>> Ans; set <pair <int, int>> St; int main() { Kultivator; cin >> N >> K; for(int i = 1; i <= N; i++){ cin >> A; St.insert({-A, i}); Dum += A; } if(Dum % K) return cout << -1, 0; while(!St.empty()){ vector <pair <int, int>> Bam; for(int i = 1; i <= K; i++){ if(!St.size()) return cout << -1, 0; pair <int, int> w = *(St.begin()); St.erase(St.begin()); Bam.pb({w.first + 1, w.second}); } Ans.pb(Bam); for(pair <int, int> i : Bam){ if(i.first) St.insert({i.first, i.second}); } } cout << Ans.size() << '\n'; for(int i = 0; i < Ans.size(); i++){ cout << 1 << ' '; for(int j = 0; j < Ans[i].size(); j++){ cout << Ans[i][j].second << ' '; } cout << '\n'; } }

Compilation message (stderr)

nicegift.cpp: In function 'int main()':
nicegift.cpp:41:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<std::pair<int, int> > >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   41 |     for(int i = 0; i < Ans.size(); i++){
      |                    ~~^~~~~~~~~~~~
nicegift.cpp:43:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   43 |         for(int j = 0; j < Ans[i].size(); j++){
      |                        ~~^~~~~~~~~~~~~~~
#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...