답안 #155241

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
155241 2019-09-27T08:51:09 Z GoldNextYear Hokej (COCI17_hokej) C++14
0 / 120
673 ms 43584 KB
#define fast ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#include <bits/stdc++.h>
using namespace std;
#define sqr 340
#define mid (l+r)/2
#define pb push_back
#define pob pop_back
#define fi first
#define se second
#define lb lower_bound
#define ub upper_bound
#define ins insert
#define era erase
#define C continue
#define mem(dp,i) memset(dp,i,sizeof(dp))
#define mset multiset
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pi> vpi;
typedef vector<pll> vpll;
const ll mod=1000000007;
const ll inf=1e18*4;
const ld pai=acos(-1);
ll m,n,sum;
vll f;
pll arr[500009];
ll st[500009];
set<pll> s1;
set<pll> s2;
vector<pair<pll,ll> >v;
int main(){
        fast;
        mem(st,-1);
        cin>>m>>n;
        for(int i=0;i<n;i++){
                ll a,b;cin>>a>>b;
                arr[i]={a,b};
                s2.ins({a*b,i});
        }
        while(s1.size()<6){
                s1.ins(*s2.rbegin());
                st[s2.rbegin()->se]=1;
                f.pb(s2.rbegin()->se);
                s2.era(*s2.rbegin());
        }
        ll M=1;
        while(M<=m){
                vector<pll>ret;
                for(auto i=s1.begin();i!=s1.end();i++){
                        sum+=arr[i->se].fi;
                        if(M-st[i->se]+1==arr[i->se].se)ret.pb(*i);
                }
                if(M<m){
                        for(auto u:ret){
                                s1.era(u);
                                s1.ins(*s2.rbegin());
                                st[s2.rbegin()->se]=M+1;
                                v.pb({{M,u.se},s2.rbegin()->se});
                                s2.era(*s2.rbegin());
                        }
                }
                M++;
        }
        cout<<sum<<endl;
        for(auto u:f)cout<<u+1<<" ";
        cout<<endl;
        cout<<v.size()<<endl;
        for(auto u:v){
                cout<<u.fi.fi<<" "<<u.fi.se+1<<" "<<u.se+1<<endl;
        }
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 5 ms 4216 KB Output isn't correct
2 Incorrect 8 ms 4728 KB Output isn't correct
3 Failed 38 ms 6264 KB CONTESTANT FOUND BETTER ANSWER THAN JURY
4 Incorrect 6 ms 4344 KB Output isn't correct
5 Incorrect 20 ms 5112 KB Output isn't correct
6 Incorrect 11 ms 4600 KB Output isn't correct
7 Incorrect 11 ms 4984 KB Output isn't correct
8 Incorrect 106 ms 12024 KB Output isn't correct
9 Failed 673 ms 43584 KB CONTESTANT FOUND BETTER ANSWER THAN JURY
10 Failed 571 ms 43448 KB CONTESTANT FOUND BETTER ANSWER THAN JURY