#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define ll long long
/// 9 12
struct player{
int k,e,id;
player(){}
player( int k, int e,int id ):k(k),e(e),id(id){}
} p[500010];
vector<pair<int,int>> event[500010];
bool cmp( player a, player b )
{
if( a.k != b.k ) return a.k>b.k;
return a.e<b.e;
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n,m;
cin>>m>>n;
for(int i=0;i<n;i++){
cin>>p[i].k >> p[i].e;
p[i].id=i+1;
}
sort( p,p+n,cmp );
vector<int>citav;
int prev=-1,time=0,tot=0,timetotal=0,sz=0;
for( int i=0;i<n;i++ ){
/// cout << i << " " << time << " " << prev << " " << timetotal << " kontas " <<endl;
if( p[i].e==m ){
citav.pb( p[i].id );
tot+=p[i].k*m;
timetotal+=m;
}
else{
event[time].pb( mp( prev, p[i].id ) );
if(time!=0)sz++;
if( timetotal + p[i].e >= 6*m ){
tot+=p[i].k*( 6*m - timetotal );
break;
}
if( time + p[i].e > m ){
event[0].pb( mp( -1, p[i].id ) );
}
time+=p[i].e;
tot+=p[i].k*p[i].e;
timetotal+=p[i].e;
if( time>=m ) time-=m;
prev=p[i].id;
}
}
cout <<tot<<endl;
for( int i=0;i<citav.size();i++ ) {
cout << citav[i] << " ";
}
// cout << " ";
for( int i=0;i<event[0].size();i++ ) cout << event[0][i].second << " ";
cout << endl;
cout<<sz<<endl;
for( int i=1;i<=m;i++ ){
for( int j=0;j<event[i].size();j++ ){
cout << i << " " << event[i][j].first << " " << event[i][j].second <<endl;
}
}
return 0;
}
Compilation message
hokej.cpp: In function 'int main()':
hokej.cpp:63:27: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for( int i=0;i<citav.size();i++ ) {
~^~~~~~~~~~~~~
hokej.cpp:67:27: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for( int i=0;i<event[0].size();i++ ) cout << event[0][i].second << " ";
~^~~~~~~~~~~~~~~~
hokej.cpp:71:31: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for( int j=0;j<event[i].size();j++ ){
~^~~~~~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
13 ms |
12024 KB |
Output is correct |
2 |
Correct |
16 ms |
12152 KB |
Output is correct |
3 |
Failed |
23 ms |
12664 KB |
the answer doesn't match with the value Z |
4 |
Correct |
14 ms |
12152 KB |
Output is correct |
5 |
Correct |
21 ms |
12280 KB |
Output is correct |
6 |
Correct |
18 ms |
12308 KB |
Output is correct |
7 |
Incorrect |
17 ms |
12284 KB |
Output isn't correct |
8 |
Incorrect |
65 ms |
14328 KB |
Output isn't correct |
9 |
Failed |
207 ms |
23100 KB |
the answer doesn't match with the value Z |
10 |
Failed |
217 ms |
23168 KB |
the answer doesn't match with the value Z |