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