标签:cas sizeof using href card efi contains lin ane
Time Limit: 6000/3000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 153 Accepted Submission(s): 71
1 //2017-08-31 2 #include <cstdio> 3 #include <cstring> 4 #include <iostream> 5 #include <algorithm> 6 7 using namespace std; 8 9 const int N = 1100000; 10 int arr[N], n; 11 bool book[N]; 12 13 int main() 14 { 15 //freopen("input1007.txt", "r", stdin); 16 while(scanf("%d", &n) != EOF){ 17 for(int i = 0; i < n; i++) 18 scanf("%d", &arr[i]); 19 sort(arr, arr+n); 20 memset(book, 0, sizeof(book)); 21 int ans = 0; 22 for(int i = 1; i < n; i++){ 23 if(i >= 2){ 24 int p1 = -1, p2 = -1; 25 for(int j = i-1; j >= 0; j--){ 26 if(arr[j] == arr[i]-1 && !book[j]){ 27 p1 = j; 28 } 29 if(arr[j] == arr[i]-2 && !book[j]){ 30 p2 = j; 31 break; 32 } 33 if(arr[j] < arr[i]-1)break; 34 } 35 if(p1 != -1 && p2 != -1){ 36 ans++; 37 book[i] = book[p1] = book[p2] = 1; 38 } 39 } 40 if(arr[i-1] == arr[i] && !book[i-1] && !book[i]){ 41 ans++; 42 book[i-1] = book[i] = 1; 43 } 44 } 45 printf("%d\n", ans); 46 } 47 48 return 0; 49 }
标签:cas sizeof using href card efi contains lin ane
原文地址:http://www.cnblogs.com/Penn000/p/7460628.html