Gadfly @ 2018-08-03 21:15:20
#include<iostream>
#include<cstring>
#include<algorithm>
#define R register
#define F(i,a,b) for(R int i=a;i<=b;i++)
#define M 200010
using namespace std;
typedef long long ll;
int w[M],v[M],LL[M],rr[M];
int n,m;
ll s,SUM,ans=0x7fffffff;
ll qs[M],qc[M];
inline int min(int a,int b){return a<b?a:b;}
inline int max(int a,int b){return a>b?a:b;}
bool check(int k)
{
SUM=0;
//F(i,0,n+1){q[i].c=0; q[i].sum=0;}
memset(qc,0,sizeof(qc));
memset(qs,0,sizeof(qs));
F(i,1,n)
{
if(w[i]>=k) {qc[i]=qc[i-1]+1; qs[i]=qs[i-1]+v[i];}
else {qc[i]=qc[i-1]; qs[i]=qs[i-1];}
}
F(i,1,m)
{
SUM+=(qc[rr[i]]-qc[LL[i]-1])*(qs[rr[i]]-qs[LL[i]-1]);//∑
}
return SUM>=s;
}
int main()
{
int l=0x7fffffff,r=-1;
//ios::sync_with_stdio(false);
scanf("%d%d%lld",&n,&m,&s);
//cout<<n<<" "<<m<<" "<<s<<endl;
F(i,1,n) {scanf("%d%d",&w[i],&v[i]); r=max(r,w[i]); l=min(l,w[i]);}
F(i,1,m) scanf("%d%d",&LL[i],&rr[i]);
l--; r++;//判断全部都选和全部都不选的情况
//cout<<l<<" "<<r<<endl;
int mid=(l+r)>>1;
while(l<=r)
{
if(check(mid)) l=mid+1;
else r=mid-1;
mid=(l+r)>>1;
ans=min(ans,llabs(SUM-s));
}
printf("%lld",ans);
return 0;
}
by ACgod @ 2018-08-03 21:26:40
题号:T31141
dalao们帮忙看看
为啥全RE
#include <bits/stdc++.h>
using namespace std;
char str[5001][5001];
char tem[5001];
int l=0;
int main()
{
for(int i=0;i<0x7ffffff;i++)
{
scanf("%s",str[i]);
for(int j=0;j<0x7fffffff;j++)
{
if(str[i][j]=='\0')
break;
if(str[i][j]>='A'&&str[i][j]<='Z')
str[i][j]+=32;
}
if(str[i][0]=='#')
{
break;
}
l++;
}
for(int i=0;i<l;i++)
{
for(int j=i+1;j<l;j++)
{
if(strcmp(str[i],str[j])>0)
{
strcpy(tem,str[i]);
strcpy(str[i],str[j]);
strcpy(str[j],tem);
}
}
}
for(int i=0;i<l;i++)
{
if(strcmp(str[i],str[i-1])==0)
{
continue;
}
printf("%s\n",str[i]);
}
}
by Fading @ 2018-08-03 21:47:45
您min max 不longlong?
by 龘靐齉齾麤 @ 2018-08-03 22:00:47
跪求各位大佬看看哪错了```c++
using namespace std; long long sb[202],fuck,mmp,a; int main() { for(a=0;a<10;a++)cin>>sb[a]; cin>>fuck; fuck+=30; for(a=0;a<10;a++)mmp+=!(fuck<sb[a]) cout<<mmp<<endl; }
by 龘靐齉齾麤 @ 2018-08-03 22:01:10
using namespace std; long long sb[202],fuck,mmp,a; int main() { for(a=0;a<10;a++)cin>>sb[a]; cin>>fuck; fuck+=30; for(a=0;a<10;a++)mmp+=!(fuck<sb[a]) cout<<mmp<<endl; }
by 龘靐齉齾麤 @ 2018-08-03 22:02:00
#include<bits/stdc++.h>
using namespace std;
long long sb[202],fuck,mmp,a;
int main()
{
for(a=0;a<10;a++)cin>>sb[a];
cin>>fuck;
fuck+=30;
for(a=0;a<10;a++)mmp+=!
(fuck<sb[a])
cout<<mmp<<endl;
}
by 龘靐齉齾麤 @ 2018-08-03 22:02:55
@一点萌
by 龘靐齉齾麤 @ 2018-08-03 22:06:50
急需[/^-^]/ ^ |____|
by 龘靐齉齾麤 @ 2018-08-03 22:13:19
if("你们给错">=1)cout<<"完成"<<endl;
else cout<<"失败"<<"骂人"<<"被罚"<<endl;
如上
by 龘靐齉齾麤 @ 2018-08-03 22:18:20
原来是个分号
by edjzy @ 2018-08-04 00:17:13
???