标签:des style blog http color io os ar java
4 4 100 4 4 4 1 2 3 4 4 3 1 1 1 1 4 2 2
4 3
1 #include <iostream> 2 #include <cstdio> 3 #include <cstring> 4 #include <cmath> 5 #include <algorithm> 6 #include <climits> 7 #include <vector> 8 #include <queue> 9 #include <cstdlib> 10 #include <string> 11 #include <set> 12 #include <stack> 13 #define LL long long 14 #define pii pair<int,int> 15 #define INF 0x3f3f3f3f 16 using namespace std; 17 int cul[100010],tmp,n,m; 18 void myscanf(int &x){ 19 char ch; 20 while((ch = getchar()) < ‘0‘ || ch > ‘9‘); 21 x = 0; 22 x = x*10 + ch - ‘0‘; 23 while((ch = getchar()) >= ‘0‘ && ch <= ‘9‘) x = x*10 + ch - ‘0‘; 24 } 25 int main() { 26 while(~scanf("%d %d",&n,&m)){ 27 for(int i = 1; i <= n; i++) 28 myscanf(cul[i]); 29 int ans = 0; 30 for(int i = 1; i <= m; i++){ 31 myscanf(tmp); 32 if(cul[tmp]){ 33 --cul[tmp]; 34 ++ans; 35 }else{ 36 for(int j = tmp; j; --j){ 37 if(cul[j]){ 38 --cul[j]; 39 ++ans; 40 break; 41 } 42 } 43 } 44 } 45 printf("%d\n",ans); 46 } 47 return 0; 48 }
标签:des style blog http color io os ar java
原文地址:http://www.cnblogs.com/crackpotisback/p/4006711.html