Submission #74546

#TimeUsernameProblemLanguageResultExecution timeMemory
74546ZZangZZangHokej (COCI17_hokej)C++17
72 / 120
184 ms6832 KiB
#include <cstdio> #include <vector> #include <algorithm> #include <queue> #include <cstring> #include <functional> #include <string> using namespace std; struct Player { int idx, K, I; bool operator<(Player const& rhs) const { return K > rhs.K; } } pls[500000]; struct Subst { int X, A, B; Subst(int X, int A, int B) : X(X), A(A), B(B) {} bool operator<(Subst const& rhs) const { return X < rhs.X; } }; int M, N; int main() { int i, j; scanf("%d%d", &M, &N); for(int i=0; i<N; ++i) { int K, I; scanf("%d %d", &K, &I); pls[i].idx = i+1; pls[i].K = K; pls[i].I = I; } sort(pls, pls+N); long long Z = 0LL; vector<int> starters; vector<Subst> substs; int remI = pls[0].I; i=0; for(int _=0; _<6; ++_) { int lastidx = pls[i].idx; starters.push_back(lastidx); int tm = remI; if(tm > M) tm = M; Z += 1LL*tm*pls[i].K; j=i; int I, K, curidx; I = tm; while(tm < M) { ++j; I = pls[j].I; K = pls[j].K; int curidx = pls[j].idx; if(I > M-tm) I = M-tm; substs.push_back(Subst(tm, lastidx, curidx)); Z += 1LL*I*K; tm += I; lastidx = curidx; } remI = pls[j].I - I; if(remI == 0) { ++j; remI = pls[j].I; } i = j; } printf("%lld\n", Z); for(i=0; i<6; ++i) { printf("%d ", starters[i]); } puts(""); sort(substs.begin(), substs.end()); int sz = substs.size(); printf("%d\n", sz); for(i=0; i<sz; ++i) { int X, A, B; X = substs[i].X; A = substs[i].A; B = substs[i].B; printf("%d %d %d\n", X, A, B); } return 0; }

Compilation message (stderr)

hokej.cpp: In function 'int main()':
hokej.cpp:53:13: warning: unused variable 'curidx' [-Wunused-variable]
   int I, K, curidx;
             ^~~~~~
hokej.cpp:28: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:31:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d %d", &K, &I);
   ~~~~~^~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...