Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- using namespace std;
- ifstream fin("numere.in");
- int main() {
- int n, x1, x2, k = 0;
- fin >> n >> x1;
- k = n - x1;
- while ((fin >> x2)) {
- if (x1 != x2) {
- k += (x1 - x2) - 1;
- }
- x1 = x2;
- }
- k += x2 - 1;
- cout << k << endl;
- return 0;
- }
Add Comment
Please, Sign In to add comment