Submission #1279447

#TimeUsernameProblemLanguageResultExecution timeMemory
1279447ghammazhassanAirplane (NOI23_airplane)C++20
0 / 100
29 ms1852 KiB
// #include <bits/stdc++.h>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <vector>
#include <iomanip>
#include <string>
#include <queue>
#include <set>
#include <deque>
using namespace std;
#define int long long
#define endl "\n"
#define fi first
#define se second
const int M=998244353;
const int inf = 1e14;
const int LOG=20;
const int N=3e5+5;
int n , m , c , w , k , t=1 , q=1 , x , y , z , l , r;
void solve()
{   
    cin >> n >> m;
    vector<int>a(n);
    for (int i=0;i<n;i++){
        cin >> a[i];
    }
    for (int i=0;i<m;i++){
        cin >> x >> y;
    }
    c=0;
    int h=0;
    for (int i=1;i<n;i++){
        c+=max(a[i]-h,1ll);
        h=max(h,a[i]);
    }
    cout << c+max(h,1ll)-1 << endl;
    
}
signed main()    
{

    ios::sync_with_stdio(0);//DO NOT USE IN INTERACTIVE
    cin.tie(0), cout.tie(0);//DO NOT USE IN INTERACTIVE
    cout << fixed << setprecision(9);
    srand(time(0));
    // int t=1;
    // cin >> t;
    for (int _=1;_<=t;_++){
        solve();
        q++;
    }
} 
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...