soham_17041998

Untitled

Dec 27th, 2019
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. /* nuttela - Soham Chakrabarti */
  2.  
  3. #include <bits/stdc++.h>
  4.  
  5. using namespace std;
  6.  
  7. #define IO ios_base::sync_with_stdio(false);cin.tie(NULL);
  8. #define endl '\n'
  9.  
  10. typedef long long ll;
  11. typedef long double ld;
  12. typedef pair <int, int> pii;
  13.  
  14. const int N = 1e3;
  15. const int inf = -1;
  16. const int MOD = 1e9 + 7;
  17.  
  18. int main() {
  19. int n, k; cin >> n >> k;
  20. int a[n];
  21.  
  22. for (int i = 0; i < n; ++i)
  23. {
  24. cin >> a[i];
  25. }
  26.  
  27. bool ok = false;
  28. for (int i = n - 1; i >= 0; --i)
  29. {
  30. if (a[i] == k) {
  31. cout << (i + 1);
  32. ok = true;
  33. break;
  34. }
  35. }
  36. if (!ok) cout << 0;
  37. return 0;
  38. }
Add Comment
Please, Sign In to add comment