Submission #343323

#TimeUsernameProblemLanguageResultExecution timeMemory
343323SprdaloGift (IZhO18_nicegift)C++17
7 / 100
2084 ms8300 KiB
/* Zharaskhan stupid ver. 1 */ #include <iostream> #include <vector> #include <algorithm> using namespace std; const int MAXN = 1e6; pair <int, int> a[MAXN]; vector< vector< int > > ans; int main() { int n, k; scanf("%d%d", &n, &k); for (int i = 0; i < n; i++) { scanf("%d", &a[i].first); a[i].second = i + 1; } bool good = true; vector <int> res; res.resize(k + 1); while (true) { sort(a , a + n, greater <pair <int, int> > ()); for (int i = 0; i < k; i++) { if (a[i].first == 0) { good = false; break; } } if (!good) { break; } int dff = 1; res[0] = dff; for (int i = 0; i < k; i++) { a[i].first -= dff; res[i + 1] = a[i].second; } ans.push_back(res); } for (int i = 0; i < n; i++) { if (a[i].first > 0) { printf("-1\n"); return 0; } } printf("%d\n", (int)ans.size()); for (int i = 0; i < ans.size(); i++) { for (int j = 0; j <= k; j++) { printf("%d ", ans[i][j]); } printf("\n"); } return 0; }

Compilation message (stderr)

nicegift.cpp: In function 'int main()':
nicegift.cpp:52:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   52 |  for (int i = 0; i < ans.size(); i++) {
      |                  ~~^~~~~~~~~~~~
nicegift.cpp:15:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   15 |  scanf("%d%d", &n, &k);
      |  ~~~~~^~~~~~~~~~~~~~~~
nicegift.cpp:17:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   17 |   scanf("%d", &a[i].first);
      |   ~~~~~^~~~~~~~~~~~~~~~~~~
#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...