Advertisement
osence

Лишние отрезки

Oct 3rd, 2020
267
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.71 KB | None | 0 0
  1. #include <fstream>
  2. #include <vector>
  3. #include <algorithm>
  4. using namespace std;
  5.  
  6. int a[1000000];
  7. int b[1000000];
  8. vector <int> answer;
  9. int main(){
  10.     int n;
  11.     ifstream fin("input.txt");
  12.     fin >> n;
  13.     for (int i=0;i<n;i++){
  14.         fin >> a[i];
  15.     }
  16.     for (int i=0;i<n;i++){
  17.         fin >> b[i];
  18.     }
  19.     for (int i=0;i<n;i++){
  20.         for (int j=i+1;j<n;j++){
  21.             if (a[i]==a[j]) continue;
  22.             if (b[i]<=a[j]) break;
  23.             if (b[i]>=b[j]) answer.push_back(j);
  24.         }
  25.     }
  26.     sort( answer.begin(), answer.end() );
  27.     answer.erase( unique( answer.begin(), answer.end() ), answer.end() );
  28.     ofstream fout("output.txt");
  29.     fout << answer.size() << endl;
  30.     for (int i=0;i<answer.size();i++){
  31.         fout << answer[i]+1 << ' ';
  32.     }
  33.     fout.close();
  34.     return 0;
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement