fork download
  1. #include<bits/stdc++.h>
  2. #include <iostream>
  3. using namespace std;
  4. //const int N = 1e5+9;
  5. //char s[N];
  6.  
  7. int main() {
  8. // your code goes here
  9. int n; cin>>n;
  10. bool watched[n+1];
  11. for(int i = 1; i<n; i++){
  12. watched[i] = false; //initially everything is false
  13. }
  14. for( int i = 1; i<n; i++){
  15. int episode; cin>> episode;
  16. watched [episode]= true;
  17. }
  18. int not_watched = -1;
  19. for(int i = 1; i<n; i++){
  20. if(!watched[i]){
  21. not_watched = i;
  22.  
  23. }
  24. }
  25. cout << not_watched << endl;
  26. assert(not_watched != -1);
  27.  
  28. return 0;
  29. }
Success #stdin #stdout 0.01s 5304KB
stdin
10
3 8 10 1 7 9 6 5 2
stdout
4