#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 500005;
const int team = 6;
struct Player {
ll k;
int dur, id;
void olvas(int i) {
id = i;
cin>>k>>dur;
}
const bool operator< (Player masik) const {
return k > masik.k;
}
};
Player tab[maxn];
int fin[maxn * team];
int n, m;
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
cin>>m>>n;
for(int i=0;i<n;i++) {
tab[i].olvas(i);
}
sort(tab,tab+n);
int it = 0;
int ben = 0;
ll summa = 0LL;
for(int i=0;i<team*m;i++) {
fin[i] = tab[it].id;
summa += tab[it].k;
ben++;
if(ben == tab[it].dur) {
ben = 0;
it++;
}
}
cout<<summa<<endl;
for(int i=0;i<team;i++) {
cout<<fin[ i*m ]+1<<" ";
}
cout<<endl;
int db = 0;
for(int j=1;j<m;j++) {
for(int i=0;i<team;i++) {
if(fin[i*m + j - 1] != fin[i*m + j]) db++;
}
}
cout<<db<<endl;
for(int j=1;j<m;j++) {
for(int i=0;i<team;i++) {
if(fin[i*m + j - 1] != fin[i*m + j]) {
cout<<j<<" "<<fin[i*m + j - 1] + 1<<" "<<fin[i*m + j] + 1<<endl;
}
}
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
424 KB |
Output is correct |
2 |
Correct |
5 ms |
640 KB |
Output is correct |
3 |
Correct |
39 ms |
12804 KB |
Output is correct |
4 |
Correct |
3 ms |
384 KB |
Output is correct |
5 |
Correct |
16 ms |
5376 KB |
Output is correct |
6 |
Correct |
5 ms |
512 KB |
Output is correct |
7 |
Incorrect |
5 ms |
640 KB |
Output isn't correct |
8 |
Incorrect |
41 ms |
4068 KB |
Output isn't correct |
9 |
Incorrect |
209 ms |
24868 KB |
Output isn't correct |
10 |
Incorrect |
198 ms |
24952 KB |
Output isn't correct |