# henrytb 的博客

### NOIP2018PJ凉凉记

posted on 2018-11-20 21:49:14 | under 游记 |

# 考场经历

T1...1分钟敲完...

string a;
while(cin>>a)ans+=a.size();

100分get...

#include <cstdio>
#include <cstdlib>
#include <iostream>
using namespace std;
int n,m,c[100005],p,s1,s2,ans;
long long ql=0,qh=0,cha=0,now=1e18;
int main(){
scanf("%d",&n);
for(int i=1;i<=n;i++) scanf("%d",&c[i]);
scanf("%d%d%d%d",&m,&p,&s1,&s2);
for(int i=1;i<m;i++)ql+=(long long)(m-i)*(long long)c[i];
for(int i=m+1;i<=n;i++)qh+=(long long)(i-m)*(long long)c[i];
if(p<m)ql+=(long long)(m-p)*(long long)s1;
else if(p>m)qh+=(long long)(p-m)*(long long)s1;
cha=ql-qh;
for(int i=1;i<m;i++){
cha+=(long long)(m-i)*(long long)s2;
if(abs(cha)<now)ans=i,now=abs(cha);
cha-=(long long)(m-i)*(long long)s2;
}
now=min(now,abs(cha));
for(int i=m+1;i<=n;i++){
cha-=(long long)(i-m)*(long long)s2;
if(abs(cha)<now)ans=i,now=abs(cha);
cha+=(long long)(i-m)*(long long)s2;
}
printf("%d\n",ans);
return 0;
}

#include <cstdio>
#include <cstdlib>
#include <iostream>
using namespace std;
int n,m,c[100005],p,s1,s2,ans;
long long ql=0,qh=0,cha=0,now=1e18;
int main(){
scanf("%d",&n);
for(int i=1;i<=n;i++) scanf("%d",&c[i]);
scanf("%d%d%d%d",&m,&p,&s1,&s2);
for(int i=1;i<m;i++)ql+=(long long)(m-i)*(long long)c[i];
for(int i=m+1;i<=n;i++)qh+=(long long)(i-m)*(long long)c[i];
if(p<m)ql+=(long long)(m-p)*(long long)s1;
else if(p>m)qh+=(long long)(p-m)*(long long)s1;
cha=ql-qh;
for(int i=1;i<m;i++){
cha+=(long long)(m-i)*(long long)s2;
if(abs(cha)<now)ans=i,now=abs(cha);
cha-=(long long)(m-i)*(long long)s2;
}
if(abs(cha)<now)ans=m,now=abs(cha);   //这一行改了
for(int i=m+1;i<=n;i++){
cha-=(long long)(i-m)*(long long)s2;
if(abs(cha)<now)ans=i,now=abs(cha);
cha+=(long long)(i-m)*(long long)s2;
}
printf("%d\n",ans);
return 0;
}

T3dp没想出来，就用贪心去骗分...

T4不会，果断输出1