#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;
}
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
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);
~~~~~^~~~~~~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
256 KB |
Output isn't correct |
2 |
Incorrect |
4 ms |
500 KB |
Output isn't correct |
3 |
Incorrect |
10 ms |
852 KB |
Output isn't correct |
4 |
Incorrect |
2 ms |
852 KB |
Output isn't correct |
5 |
Incorrect |
5 ms |
852 KB |
Output isn't correct |
6 |
Incorrect |
3 ms |
852 KB |
Output isn't correct |
7 |
Incorrect |
5 ms |
852 KB |
Output isn't correct |
8 |
Incorrect |
35 ms |
1960 KB |
Output isn't correct |
9 |
Incorrect |
170 ms |
6724 KB |
Output isn't correct |
10 |
Incorrect |
169 ms |
6736 KB |
Output isn't correct |