记录编号 |
310822 |
评测结果 |
AAAAAAAAAAAAAAAAAAAA |
题目名称 |
从零开始的生存时间 |
最终得分 |
100 |
用户昵称 |
沉迷学习的假的Keller |
是否通过 |
通过 |
代码语言 |
C++ |
运行时间 |
30.526 s |
提交时间 |
2016-09-23 15:08:16 |
内存使用 |
53.62 MiB |
显示代码纯文本
- #include<algorithm>
- #include<cassert>
- #include<cstdio>
- #include<cstring>
- #include<iostream>
- #include<string>
- #include<vector>
- using namespace std;
- const int maxn=10000000+10;
- int n,m;
- long long a[maxn],ans,k;
- inline void read(long long &x){
- char ch;
- while(ch=getchar(),ch<48||ch>57);
- x=ch-48;
- while(ch=getchar(),ch>47&&ch<58)x=x*10+ch-48;
- }
- int MAIN(){
- freopen("Re_Rest.in","r",stdin);
- freopen("Re_Rest.out","w",stdout);
- scanf("%d",&n);
- for(int i=1;i<=n;i++){
- read(a[i]);
- }
- sort(a+1,a+n+1);
- scanf("%d",&m);
- for(int i=1;i<=m;i++){
- ans=0;
- read(k);
- int l=1,r=n;
- while(l<r){
- if(k<(a[l]+a[r])){
- r--;
- }
- else{
- ans+=r-l;
- l++;
- }
- }
- printf("%lld\n",ans);
- }
- }
- int main(){;}
- int helenkeller=MAIN();