제출 #1056649

#제출 시각아이디문제언어결과실행 시간메모리
1056649AmirAli_H1송신탑 (IOI22_towers)C++17
14 / 100
571 ms2900 KiB
// In the name of Allah #include <bits/stdc++.h> #include "towers.h" using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; #define F first #define S second #define all(x) (x).begin(),(x).end() #define len(x) ((ll) (x).size()) #define Mp make_pair #define pb push_back #define endl '\n' #define sep ' ' const int maxn = 1e5 + 7; const ll oo = 1e9 + 7; int n; ll A[maxn]; int M[maxn], sm[maxn]; void init(int N, vector<int> H) { n = N; for (int i = 0; i < n; i++) A[i] = H[i]; for (int i = 1; i < n - 1; i++) { if (A[i] < A[i - 1] && A[i] < A[i + 1]) M[i] = 1; else M[i] = 0; } for (int i = 1; i <= n; i++) sm[i] = sm[i - 1] + M[i - 1]; } int max_towers(int L, int R, int D) { int res = sm[R + 1] - sm[L]; if (R - L + 1 == 1) { if (M[L] == 0) res++; } else { if (M[L] == 0 && A[L] < A[L + 1]) res++; if (M[R] == 0 && A[R] < A[R - 1]) res++; } return res; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...