title: Performance comparison between three ways to read and store an array of objects
body: <p>I'm trying to improve my coding skills in problem-solving using C++. Hence, I'm curious to know which one of the following three suggested examples is faster and better to use, as well as the best way to evaluate the performance.</p>
  
  <pre><code>#include &lt;bits/stdc++.h&gt;
  
  using namespace std;
  
  const int N = 1e5;
  
  struct Car {
      int id, price;
      Car(int _id, int _price) : id(_id), price(_price) {}
  };
  
  struct Boat {
      int id, price;
  };
  
  struct Motorcycle {
      int id, price;
  };
  
  int main() {
      // ------------ section1 ------------
      int n1;
      scanf("%d", &amp;n1);
      vector&lt;Car&gt; cars;
      for (int i = 0; i &lt; n1; i++) {
          int id, price;
          scanf("%d%d", &amp;id, &amp;price);
          cars.emplace_back(id, price);
      }
      // ------------ section2 ------------
      int n2;
      scanf("%d", &amp;n2);
      Boat boats[N];
      for (int i = 0; i &lt; n2; i++) {
          int id, price;
          scanf("%d%d", &amp;id, &amp;price);
          boats[i] = {id, price};
      }
      // ------------ section3 ------------
      int n3;
      scanf("%d", &amp;n3);
      vector&lt;Motorcycle&gt; motorcycles(n3);
      for (auto&amp; motorcycle : motorcycles) {
          scanf("%d%d", &amp;motorcycle.id, &amp;motorcycle.price);
      }
      return 0;
  }
  </code></pre>
  
  <p>However, I believe that the ordinary array is faster than the <code>std::vector</code>.</p>