标签:style blog color io for 代码 div ar
#include<stdio.h> #define MAX 100000+5 int a[MAX]; int main() { int n,m,i,j,k,v; while( scanf("%d %d",&n,&m)!=EOF) { for(i=1;i<=n;i++) scanf("%d",&a[i]); while(m--) { scanf("%d %d",&k,&v); int tot=0; for(i=1;i<=n;i++) { if(a[i]==v) tot++; if(tot==k) break; } if(i<=n) printf("%d\n",i); else printf("0\n"); } } return 0; }
#include<map> #include<stdio.h> #include<vector> using namespace std; int main() { map >a;//最后两个> >要分开,不然会误认为是>> int n,m,i,j,temp,k,v; while(scanf("%d %d",&n,&m)!=EOF) { a.clear(); for(i=1;i<=n;i++) { scanf("%d",&temp); if(a.find(temp)==a.end())//也可是!a.count(temp) a[temp]=vector(); a[temp].push_back(i); } for(i=1;i<=m;i++) { scanf("%d %d",&k,&v); if(a.find(v)==a.end()||k>a[v].size())//也可是!a.count(temp)||k>a[v].size() printf("0\n"); else printf("%d\n",a[v][k-1]); } } return 0; }
Uva 11991 - Easy Problem from Rujia Liu?,布布扣,bubuko.com
Uva 11991 - Easy Problem from Rujia Liu?
标签:style blog color io for 代码 div ar
原文地址:http://www.cnblogs.com/hzwangzi123456/p/3872744.html