#include<iostream>
#include<algorithm>
#define DIM 500005
using namespace std;
int m, n, i, j, nr, ii, jj, u;
long long sol;
int a[7][DIM];
struct str{
int val, t, ind;
};
str v[DIM];
int cmp(str a, str b){
return a.val > b.val;
}
int main(){
cin>> m >> n;
for(i = 1; i <= n; i++){
cin>> v[i].val >> v[i].t;
v[i].ind = i;
}
sort(v + 1, v + n + 1, cmp);
ii = jj = u = 1;
for(i = 1; i <= m * 6; i++){
if(v[u].t == 0){
u++;
}
sol += v[u].val;
v[u].t--;
a[ii][jj] = v[u].ind;
jj++;
if(jj == m + 1){
jj = 1;
ii++;
}
}
cout<< sol <<"\n";
for(i = 1; i <= 6; i++){
cout<< a[i][1] <<" ";
}
cout<<"\n";
for(i = 1; i <= 6; i++){
for(j = 2; j <= m; j++){
if(a[i][j] != a[i][j - 1]){
nr++;
}
}
}
cout<< nr <<"\n";
for(j = 2; j <= m; j++){
for(i = 1; i <= 6; i++){
if(a[i][j] != a[i][j - 1]){
cout<< j <<" "<< a[i][j - 1] <<" "<< a[i][j] <<"\n";
}
}
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
376 KB |
Integer 50 violates the range [1, 49] |
2 |
Failed |
8 ms |
504 KB |
some player fainted |
3 |
Failed |
55 ms |
12664 KB |
some player fainted |
4 |
Failed |
3 ms |
504 KB |
some player fainted |
5 |
Failed |
22 ms |
5368 KB |
some player fainted |
6 |
Incorrect |
5 ms |
376 KB |
Integer 350 violates the range [1, 349] |
7 |
Incorrect |
10 ms |
632 KB |
Output isn't correct |
8 |
Incorrect |
94 ms |
3576 KB |
Output isn't correct |
9 |
Incorrect |
557 ms |
22904 KB |
Output isn't correct |
10 |
Incorrect |
540 ms |
22868 KB |
Output isn't correct |