标签:c style class blog code java
水题,不过要想0ms过还是有个技巧的:
#include <iostream> #include <cstring> using namespace std; int main() { int score[101]; int t,t1,temp; while(cin>>t) { //memset(score,0,sizeof(score));这样时效性不高了,因为memset()是按字节处理数据的,并且有个函数调用的过程 for (int i=0;i<101;i++) { score[i]=0; } while(t--) { //cin>>temp; scanf("%d",&temp); score[temp]++; } for (int i=1;i<101;i++) { score[i]+=score[i-1]; } scanf("%d",&t); //cin>>t; while(t--) { scanf("%d%d",&t1,&temp); //cin>>t1>>temp; if (t1==0) { cout<<score[temp]<<endl; } else cout<<score[temp]-score[t1-1]<<endl; } } return 0; }
FOJ_Problem 1587 成绩统计,布布扣,bubuko.com
标签:c style class blog code java
原文地址:http://www.cnblogs.com/siaimes-sunzs/p/3760315.html