Cod sursa(job #2050406)
Utilizator | Theodor Negrescu theo2003 | Data | 28 octombrie 2017 09:48:24 |
---|---|---|---|
Problema | Deque | Scor | 0 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.49 kb |
#include <fstream>
int main(){
int n, k;
std::ifstream in("deque.in");
long long int result = 0;
in>>n>>k;
std::pair<int, int> last;
in>>last.first>>last.second;
int tmp, minn = std::min(last.first, last.second);
for(int x = 2;x<n;x++){
in>>tmp;
result+=std::min(minn, tmp);
last.first = last.second;
last.second = tmp;
minn = std::min(last.first, last.second);
}
std::ofstream("deque.out")<<result;
}