比赛 |
NOIP模拟赛by mzx Day1 |
评测结果 |
WAWWWWTTTT |
题目名称 |
昆特-冠位指定 |
最终得分 |
10 |
用户昵称 |
cdcq |
运行时间 |
4.334 s |
代码语言 |
C++ |
内存使用 |
4.06 MiB |
提交时间 |
2016-10-19 21:57:52 |
显示代码纯文本
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
using namespace std;
int read(){int z=0,mark=1; char ch=getchar();
while(ch<'0'||ch>'9'){if(ch=='-')mark=-1; ch=getchar();}
while(ch>='0'&&ch<='9'){z=(z<<3)+(z<<1)+ch-'0'; ch=getchar();}
return z*mark;
}
struct cdd{int pvalue,z,power,id,j;}a[110000],j[110000]; int at=0,jt=0;
int n,m,t;
long long dp=0;
long long bowl=0;
long long bbowl=0;
int ans=0;
bool compare(cdd x,cdd y){ return x.pvalue<y.pvalue;}
int main(){
//freopen("ddd.in","r",stdin);
freopen("gwent_grandorder.in","r",stdin);
freopen("gwent_grandorder.out","w",stdout);
cin>>n>>m>>t;
int _value,_z,_power,_id,_j;
for(int i=1;i<=m;i++){
_value=read(),_z=read(),_power=read(),_id=read(),_j=read();
if(!_j) dp+=_power;
else bowl+=_power,bbowl+=_power;
}
for(int i=1;i<=n;i++){
_value=read(),_z=read(),_power=read(),_id=read(),_j=read();
if(!_j){ at++; a[at].pvalue=_value,a[at].z=_z,a[at].power=_power,a[at].id=_id,a[at].j=_j; bbowl+=_power;}
else{ jt++; a[jt].pvalue=_value,a[jt].z=_z,a[jt].power=_power,a[jt].id=_id,a[jt].j=_j;}
}
if(bbowl<dp){ cout<<"SingleDogMZX"<<endl; return 0;}
sort(a+1,a+at+1,compare),sort(j+1,j+jt+1,compare);
int ate=1,jte=1;
for(;ate<=t && ate<=at && bowl<dp;ate++){
bowl+=a[ate].power;
ans=max(ans,a[ate].pvalue);
}
if(bowl<dp)
for(;jte<=jt;jte++){
dp+=j[jte].power;
ans=max(ans,j[jte].pvalue);
ate++;
if(ate>at) break;
ans=max(ans,a[ate].pvalue);
bowl+=a[ate].power;
if(bowl>=dp) break;
ate++;
if(ate>at) break;
ans=max(ans,a[ate].pvalue);
bowl+=a[ate].power;
if(bowl>=dp) break;
}
if(bowl<dp) cout<<"SingleDogMZX"<<endl;
else cout<<ans<<endl;
return 0;
}