Skip to content

Instantly share code, notes, and snippets.

@invatainfo
Created February 15, 2020 16:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save invatainfo/ab247e44e7b7a7fee8045a99a96b7619 to your computer and use it in GitHub Desktop.
Save invatainfo/ab247e44e7b7a7fee8045a99a96b7619 to your computer and use it in GitHub Desktop.
#include <iostream>
#include <fstream>
using namespace std;
int main() {
ifstream f("numere.in");
int n, x, count = 0;
f >> n;
while (f >> x) {
if (n > x) {
count += n - x;
}
n = x - 1;
}
count += n;
cout << count << endl;
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment