답안 #886203

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
886203 2023-12-11T14:56:58 Z vjudge1 Airplane (NOI23_airplane) C++17
0 / 100
132 ms 3776 KB
#include <bits/stdc++.h>

#define int long long int
#define MP make_pair
#define REP(i,n) for(int (i) = 0; (i)<(n); (i)++)
#define pb push_back

const int N = 2e5+5;
const int M = 4e5+5;
const int MOD = 1e9+7;
const int INF = 1e17;
using namespace std;

void fastio() {
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
}
int n,m,q;
vector<int> a(N, 0);

void solve() {
    cin>>n>>m;
    REP(i,n) cin>>a[i + 1];
    for(int i = 1; i<=m; i++) {
        int u,v;
        cin>>u>>v;
    }
    a[0] = -5;
    int mx = 0;
    REP(i,n) {
        if(a[mx] <= a[i + 1]) mx = i + 1;
    }
    int cost = 0;
    int curh = 0;
    for(int i = 2; i<=mx; i++) {
        cost++; curh++;
        if(curh < a[i]) {
            cost += a[i] - curh;
            curh = a[i];
        }
    }
    for(int i = mx + 1; i<=n; i++) {
        cost++;
        if(curh > a[i]) {
            curh--;
        }
    }
    cost += curh;
    cout<<cost<<"\n";

}

signed main() {
    // fastio();
    solve();
}   

Compilation message

Main.cpp: In function 'void solve()':
Main.cpp:5:26: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
    5 | #define REP(i,n) for(int (i) = 0; (i)<(n); (i)++)
      |                          ^
Main.cpp:23:5: note: in expansion of macro 'REP'
   23 |     REP(i,n) cin>>a[i + 1];
      |     ^~~
Main.cpp:5:26: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
    5 | #define REP(i,n) for(int (i) = 0; (i)<(n); (i)++)
      |                          ^
Main.cpp:30:5: note: in expansion of macro 'REP'
   30 |     REP(i,n) {
      |     ^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1880 KB Output is correct
2 Incorrect 132 ms 3776 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1884 KB Output is correct
2 Incorrect 1 ms 1880 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1884 KB Output is correct
2 Incorrect 1 ms 1880 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1880 KB Output is correct
2 Incorrect 132 ms 3776 KB Output isn't correct
3 Halted 0 ms 0 KB -