# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
155241 | GoldNextYear | Hokej (COCI17_hokej) | C++14 | 673 ms | 43584 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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;
}
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |