fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. #define ms(s,n) memset(s,n,sizeof(s))
  5. #define all(a) a.begin(),a.end()
  6. #define present(t, x) (t.find(x) != t.end())
  7. #define sz(a) int((a).size())
  8. #define FOR(i, a, b) for (int i = (a); i < (b); ++i)
  9. #define FORd(i, a, b) for (int i = (a) - 1; i >= (b); --i)
  10. #define pb push_back
  11. #define pf push_front
  12. #define fi first
  13. #define se second
  14. #define mp make_pair
  15.  
  16. typedef long long ll;
  17. typedef unsigned long long ull;
  18. typedef long double ld;
  19. typedef pair<int,int> pi;
  20. typedef vector<int> vi;
  21. typedef vector<pi> vii;
  22.  
  23. const int MOD = (int) 1e9+7;
  24. const int INF = (int) 1e9+1;
  25. inline ll gcd(ll a,ll b){ll r;while(b){r=a%b;a=b;b=r;}return a;}
  26. inline ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
  27.  
  28.  
  29. int main(){
  30. #ifndef ONLINE_JUDGE
  31. freopen("input.txt", "r", stdin);
  32. freopen("output.txt", "w", stdout);
  33. #endif
  34. int n, m; cin >> n >> m;
  35. int b[n], c[m];
  36. for(int i = 0; i < n; i++) cin >> b[i];
  37. for(int i = 0; i < m; i++) cin >> c[i];
  38. int i = 0, j = 0;
  39. while(i < n && j < m){
  40. if(b[i] <= c[j]){
  41. cout << "b"<< i + 1 << " ";
  42. ++i;
  43. }
  44. else{
  45. cout << "c" << j + 1 << " ";
  46. ++j;
  47. }
  48. }
  49. while(i < n){
  50. cout << "b"<< i + 1 << " ";
  51. ++i;
  52. }
  53. while(j < m){
  54. cout << "c" << j + 1 << " ";
  55. ++j;
  56. }
  57. return 0;
  58. }
  59.  
Time limit exceeded #stdin #stdout 5s 5592KB
stdin
Standard input is empty
stdout
Standard output is empty