Submission #79853

#TimeUsernameProblemLanguageResultExecution timeMemory
79853pzdbaHokej (COCI17_hokej)C++14
72 / 120
180 ms10704 KiB
#include <bits/stdc++.h> using namespace std; typedef long long LL; typedef pair<int, int> pii; typedef pair<pii, int> piipi; int k[500005], l[500005]; piipi p[500005]; vector<int> ans1; vector<piipi> ans2; int main(){ int m, n; scanf("%d%d", &m, &n); for(int i=1;i<=n;i++){ scanf("%d%d", &k[i], &l[i]); p[i] = piipi(pii(-k[i], l[i]), i); } sort(p+1, p+1+n); LL ans = 0; int cur = 1, tot = 0, pv = -1; for(int i=1;i<=n;i++){ int idx = p[i].second; if(tot == 0) ans1.emplace_back(idx); else if(pv != -1 && tot != m) ans2.emplace_back(piipi(pii(tot, pv), idx)); if(tot+l[idx] <= m){ tot += l[idx]; ans += (LL)l[idx]*k[idx]; if(tot == m){ cur++; tot = 0; if(cur > 6) break; } } else{ ans += (LL)(m-tot)*k[idx]; l[idx] = l[idx] - (m-tot); i--; cur++; tot = 0; if(cur > 6) break; } pv = idx; } printf("%lld\n", ans); for(int i=0;i<ans1.size();i++) printf("%d ", ans1[i]); printf("\n"); sort(ans2.begin(), ans2.end()); printf("%d\n", ans2.size()); for(int i=0;i<ans2.size();i++) printf("%d %d %d\n", ans2[i].first.first, ans2[i].first.second, ans2[i].second); }

Compilation message (stderr)

hokej.cpp: In function 'int main()':
hokej.cpp:46:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i=0;i<ans1.size();i++) printf("%d ", ans1[i]);
              ~^~~~~~~~~~~~
hokej.cpp:49:28: warning: format '%d' expects argument of type 'int', but argument 2 has type 'std::vector<std::pair<std::pair<int, int>, int> >::size_type {aka long unsigned int}' [-Wformat=]
  printf("%d\n", ans2.size());
                 ~~~~~~~~~~~^
hokej.cpp:50:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i=0;i<ans2.size();i++) printf("%d %d %d\n", ans2[i].first.first, ans2[i].first.second, ans2[i].second);
              ~^~~~~~~~~~~~
hokej.cpp:12:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d", &m, &n);
  ~~~~~^~~~~~~~~~~~~~~~
hokej.cpp:14:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d%d", &k[i], &l[i]);
   ~~~~~^~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...