Submission #342673

#TimeUsernameProblemLanguageResultExecution timeMemory
342673RakhmandGift (IZhO18_nicegift)C++14
30 / 100
2094 ms211464 KiB
// // main.cpp // torelax // // Created by Rakhman on 11/15/20. // #include <cstring> #include <vector> #include <list> #include <map> #include <set> #include <deque> #include <stack> #include <bitset> #include <algorithm> #include <functional> #include <numeric> #include <utility> #include <sstream> #include <iostream> #include <iomanip> #include <cstdio> #include <queue> #include <cmath> #include <cstdlib> #include <ctime> #include <cassert> #include <iterator> #define ios ios_base::sync_with_stdio(0), cout.tie(0), cin.tie(0); #define S second #define F first #define pb push_back #define nl '\n' #define NL cout << '\n'; #define EX exit(0) #define all(s) s.begin(), s.end() #define no_answer {cout << "NO"; exit(0);} #define FOR(i, start, finish, k) for(llong i = start; i <= finish; i += k) const long long mxn = 2e6 + 110; const long long mnn = 1e1 + 1; const long long mod = 1e9 + 7; const long long inf = 1e18; const long long OO = 1e11; typedef long long llong; typedef unsigned long long ullong; using namespace std; int n, k; set<pair<int, int> > st; llong sum = 0; int main() { cin >> n >> k; for(int i = 1; i <= n; i++){ int x; cin >> x; st.insert({-x, i}); sum += x; } if(sum % k != 0){ cout << -1; return 0; } vector<vector<pair<int, int> > > ans; while(st.size() != 0){ vector<pair<int, int> > kek; for(int i = 1; i <= k; i++){ if(st.size() == 0){ cout << -1; return 0; } pair<int, int> x = *(st.begin()); st.erase(st.begin()); kek.push_back({x.F + 1, x.S}); } ans.push_back(kek); for(int i = 0; i < kek.size(); i++){ if(kek[i].F != 0){ st.insert({kek[i].F, kek[i].S}); } } } cout << ans.size() << nl; for(int i = 0; i < ans.size(); i++){ cout << 1 << ' '; for(int j = 0; j < ans[i].size(); j++){ cout << ans[i][j].S << ' '; } cout << nl; } }

Compilation message (stderr)

nicegift.cpp: In function 'int main()':
nicegift.cpp:82: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]
   82 |         for(int i = 0; i < kek.size(); i++){
      |                        ~~^~~~~~~~~~~~
nicegift.cpp:89: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]
   89 |     for(int i = 0; i < ans.size(); i++){
      |                    ~~^~~~~~~~~~~~
nicegift.cpp:91: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]
   91 |         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...