极限速度1.13s
为尽量减少赋值次数,使用了传引用。亲测位运算甚至比此版本慢0.1s,printf慢0.01s
有没有dalao能给他优化到1s内
记录:目前极限
#include <bits/stdc++.h>
using namespace std;
#define maxn 1<<16
int now=maxn;
char in[maxn];
int ans,n,ls;
inline void getch(char &a){
if(now==maxn){
fread(in,maxn,1,stdin);
now=0;
}
a=in[now++];
}
inline void read(int &a){
int out=0;
bool sf=0;
char get;
getch(get);
while(get<'0'){
if(get=='-'){
sf=1;
break;
}
getch(get);
}
while(get<'0'){
getch(get);
}
while(get>='0'){
out*=10;
out+=get-'0';
getch(get);
}
if(sf)out=-out;
a+=out;
}
int main(){
read(n);
for(int i=0;i<n;i++){
read(ans);
}
cout<<ans;
return 0;
}