Untitled
unknown
plain_text
a month ago
825 B
2
Indexable
#include <iostream> #include <vector> using namespace std; int main() { int t; //cout << "t: "; cin >> t; for (int i = 0; i < t; i++) { // case-lerin sayi int n; //cout << "n: "; cin >> n; vector<int> vect; vect.reserve(n); for (int j = 0; j < n; ++j) { // vectoru doldurmaq int v; //cout << "v" << (j + 1) << ": "; cin >> v; vect.push_back(v); } while (vect.size() != 1) { int a = vect.back(); // pop a vect.pop_back(); int b = vect.back(); vect.back() = a + b - 1; } //cout << "result: "; cout << vect.back() << '\n'; } return 0; }
Editor is loading...
Leave a Comment