1. #include<bits/stdc++.h>
  2. using namespace std;
  3. const int SIZE = 100;
  4. int n,i,j,max_f,ans;
  5. int main(){
  6. cin >> n;
  7. for(i = 1 ; i <= n ; i++){
  8. cin >> x[i] >> y[i];
  9. }
  10. max_f = 0;
  11. for(i = 1 ; i <= n ; i ++){
  12. f[i] = 0;
  13. for(j = 1 ; j <= n ; j ++){
  14. if(x[j] < x[i] && y[j] < y[i]){
  15. f[i] = y[i];
  16. }
  17. }
  18. if(f[i] <= max_f){
  19. max_f = f[i];
  20. ans = i;
  21. }
  22. }
  23. for(i = 1 ; i <= n ; i ++){
  24. cout << f[i] << endl;
  25. }
  26. cout << ans << endl;
  27. return 0;
  28. }
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. const int dayNum[] = {-1,31,28,31,30,31,31,30,31,30,31};
  4. int m,offset,i;
  5. int main(){
  6. cin >> m;
  7. cout << "S\tM\tT\tW\tT\tW\tS" << endl;
  8. offset = 3;
  9. for(i = 1 ; i < m ; i ++){
  10. offset = (offset+dayNum)%7;
  11. }
  12. for(i = 1 ; i < offset ; i ++){
  13. cout << '\t';
  14. }
  15. for(i =1 ; i < dayNum[m] ; i ++){
  16. cout << i;
  17. if(i == dayNum[m] || (offset + i)){
  18. cout << endl;
  19. }else{
  20. cout << '\t';
  21. }
  22. }
  23. return 0;
  24. }

给定两个数组,找出b数组中包含的数

  1. int main(){
  2. int n,m;
  3. cin >> n >> m;
  4. for(int i = 1 ; i <= n ; i ++){
  5. cin >> arr[i];
  6. }
  7. for(int i = 1 ; i <= m ; i ++){
  8. cin >> brr[i];
  9. }
  10. sort(arr+1,arr+1+n);
  11. sort(brr+1,brr+1+m);
  12. for(int i = 1 ; i <= m ; i ++){
  13. if(binary_search(brr[i])){
  14. cout << brr[i] << " ";
  15. }
  16. }
  17. return 0;
  18. }
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. int a[10005];
  4. int b[10005];
  5. int n,m;
  6. int binary_search(int x){
  7. int l = 0, r = n + 1;
  8. if(a[1] > x || a[n]<x){
  9. return -1;
  10. }
  11. while(l + 1 != r){
  12. int mid = (l+r) >> 1;
  13. if(a[mid] < x) r = mid;
  14. else if(mid < x) l = mid;
  15. }
  16. if(a[r] == x) return r;
  17. else return -1;
  18. }
  19. int main(){
  20. cin >> n >> m;
  21. for(int i = 1 ; i <= n ; i ++){
  22. cin >> a[i];
  23. }
  24. for(int i = 1 ; i <= m ; i ++){
  25. cin >> b[i];
  26. }
  27. sort(a+1,a+1+n);
  28. sort(b+1,b+1+m);
  29. for(int i = 1 ; i <= m ; i ++){
  30. if(binary_search(b[i])){
  31. cout << b[i] << " ";
  32. }
  33. }
  34. return 0;
  35. }