全是水题。。。。又在浪费生命。。。。
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <string>
using namespace std;
long long int low,high;
int main()
{
int n;
long long int num;
string type,re;
cin>>n;
low=-1e9-10;
high=1e9+10;
for(int i=0;i<n;i++)
{
cin>>type>>num>>re;
if(type==">")
{
if(re=="Y") low=max(low,num+1);
else high=min(high,num);
}
else if(type==">=")
{
if(re=="Y") low=max(low,num);
else high=min(high,num-1);
}
else if(type=="<")
{
if(re=="Y") high=min(high,num-1);
else low=max(low,num);
}
else if(type=="<=")
{
if(re=="Y") high=min(high,num);
else low=max(low,num+1);
}
}
if(high>=low)
cout<<(high+low)/2<<endl;
else
puts("Impossible");
return 0;
}
#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
using namespace std;
int m,n;
int t[55000][7];
int time[2][55000];
int main()
{
scanf("%d%d",&m,&n);
for(int i=1;i<=m;i++)
{
for(int j=1;j<=n;j++)
{
scanf("%d",&t[i][j]);
}
}
for(int i=1;i<=n;i++)
{
for(int j=1;j<=m;j++)
{
time[i%2][j]=max(time[i%2][j-1]+t[j][i],time[(i-1)%2][j]+t[j][i]);
}
}
for(int i=1;i<=m;i++)
printf("%d ",time[n%2][i]);
return 0;
}
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
int n,m;
struct VS
{
int c,p,id,tb;
}vit[1100];
bool cmp(VS a,VS b)
{
if(a.p!=b.p) return a.p>b.p;
return a.c<b.c;
}
struct Table
{
int cp,id,tk;
}r[1100];
bool cmp2(Table a,Table b)
{
return a.cp<b.cp;
}
int main()
{
scanf("%d",&n);
for(int i=0;i<n;i++)
{
int C,P;
scanf("%d%d",&C,&P);
vit[i]=(VS){C,P,i,-1};
}
sort(vit,vit+n,cmp);
scanf("%d",&m);
for(int i=0;i<m;i++)
{
int R;
scanf("%d",&R);
r[i]=(Table){R,i,0};
}
sort(r,r+m,cmp2);
int mxpeople=r[m-1].cp;
int ans=0,sum=0;
for(int i=0;i<n;i++)
{
if(vit[i].c>mxpeople) continue;
for(int j=0;j<m;j++)
{
if(vit[i].c>r[j].cp) continue;
if(r[j].tk==0)
{
r[j].tk=1;
vit[i].tb=r[j].id;
ans++; sum+=vit[i].p;
break;
}
}
}
cout<<ans<<" "<<sum<<endl;
for(int i=0;i<n;i++)
{
if(vit[i].tb!=-1)
cout<<vit[i].id+1<<" "<<vit[i].tb+1<<endl;
}
return 0;
}