c++(196ms 82%) simple, easy, small (STL)
Runtime: 196 ms, faster than 82.30% of C++ online submissions for Snapshot Array.\nMemory Usage: 93.6 MB, less than 54.41% of C++ online submissions for Snapsho
Runtime: 196 ms, faster than 82.30% of C++ online submissions for Snapshot Array.\nMemory Usage: 93.6 MB, less than 54.41% of C++ online submissions for Snapshot Array.\n```\nclass SnapshotArray {\npublic:\n  vector<vector<pair<int,int>>> v;\n  int sn;\n  \n  SnapshotArray(int length){\n    v.resize(length, vector<pair<int,int>>(1, pair<int,int>({0,0})));\n    sn = 0;\n  }\n    \n  void set(int index, int val){\n    v[index].push_back({sn, val});\n  }\n    \n  int snap() {\n    return sn++;  \n  }\n    \n  int get(int i, int s_id){\n    return v [i] [upper_bound(v[i].begin(), v[i].end(), s_id, comp) - v[i].begin() - 1] .second;  \n  }\n  \n  static bool comp(int n, pair<int,int> &p){\n    return p.first > n;\n  }\n};\n```
['C', 'C++']