#include <iostream>
#include <algorithm>
using namespace std;
struct player {
long long value;
long long resistence;
long long position;
};
struct ch {
long long minute;
long long enter;
long long exit;
};
player v[500010];
ch Change[1000001];
long long Start[7];
long long change, start, n, m, rest, lin, col, i, j, sol, last;
long long cmp(const player &a, const player &b) {
if (a.value != b.value)
return a.value > b.value;
else
return a.resistence > b.resistence;
}
long long cmp1(const ch &a, const ch &b) {
return a.minute < b.minute;
}
int main () {
cin>>m>>n;
for (i=1;i<=n;i++) {
cin>>v[i].value>>v[i].resistence;
v[i].position = i;
}
sort(v+1, v+n+1, cmp);
for (i=1;i<=n;i++) {
cout<<v[i].value<<" "<<v[i].resistence<<" "<<v[i].position<<"\n";
}
for (i=1;i<=6;i++) {
if (v[i].resistence < m) {
break;
}
Start[i] = v[i].position;
start = i;
sol += v[i].value * m;
}
rest = 6*m - (i-1)*m;
last = -1;
col = 1;
for (j=i;j<=n;j++) {
if (col == 1) {
start++;
Start[start] = v[j].position;
}
if (col != 1) {
Change[++change].minute = col;
Change[change].enter = v[j].position;
Change[change].exit = last;
}
last = v[j].position;
if (rest <= v[j].resistence) {
sol += rest * v[j].value;
break;
}else {
if (col + v[j].resistence <= m) {
col += v[j].resistence;
} else
if (col + v[j].resistence == m+1) {
last =-1;
col = 1;
} else {
Start[++start] = v[j].position;
col = v[j].resistence - (m-col);
}
rest -= v[j].resistence;
sol += v[j].resistence * v[j].value;
}
}
sort(Change+1, Change+change+1, cmp1);
cout<<sol<<"\n";
for (i=1;i<=6;i++)
cout<<Start[i]<<" ";
cout<<"\n";
cout<<change<<"\n";
for (i=1;i<=change;i++)
cout<<Change[i].minute-1<<" "<<Change[i].exit<<" "<<Change[i].enter<<"\n";
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
376 KB |
Integer 99053 violates the range [1, 102] |
2 |
Incorrect |
10 ms |
632 KB |
Integer 3218 violates the range [1, 2799] |
3 |
Incorrect |
37 ms |
1628 KB |
Integer 99925 violates the range [1, 25002] |
4 |
Incorrect |
3 ms |
376 KB |
Integer 99422 violates the range [1, 500] |
5 |
Incorrect |
15 ms |
888 KB |
Output isn't correct |
6 |
Incorrect |
6 ms |
504 KB |
Integer 1763 violates the range [1, 349] |
7 |
Incorrect |
13 ms |
760 KB |
Integer 5110 violates the range [1, 1499] |
8 |
Incorrect |
125 ms |
5100 KB |
Integer 66270 violates the range [1, 49999] |
9 |
Incorrect |
686 ms |
24464 KB |
Output isn't correct |
10 |
Incorrect |
686 ms |
24544 KB |
Output isn't correct |