Submission #238752

#TimeUsernameProblemLanguageResultExecution timeMemory
238752Dynamic_CastPilot (NOI19_pilot)C++14
40 / 100
51 ms3320 KiB
//#include <bits/stdc++.h> C++11 #include <iostream> #include <vector> #include <string> #include <algorithm> #include <cmath> #include <stdio.h> #include <time.h> #include <iomanip> #include <stdlib.h> #include <list> #include <stack> #include <queue> #include <climits> #include <map> #include <set> #include <sstream> using namespace std; typedef long long ll; typedef pair<int, int> pi; typedef vector<int> vi; #define PB push_back #define MP make_pair int main() { ios::sync_with_stdio(0); cin.tie(0); int N, Q, flag, f; cin >> N >> Q; vi height(N, 0); vi plane(Q, 0); flag = 1; f = 0; cin >> height[0]; for (int i = 1; i < N; i++) { cin >> height[i]; if (height[i] < height[i - 1]) { f = 1; } } if (f == 1) { flag = 0; } for (int i = 0; i < Q; i++) { cin >> plane[i]; } int num; int sum; int index; for (int i = 0; i < Q; i++) { sum = 0; if (flag == 0) { num = 0; for (int j = 0; j < N; j++) { num++; if (height[j] > plane[i]) { sum += (num * (num - 1)) / 2; num = 0; } else { if (j == N - 1) { sum += (num * (num + 1)) / 2; } } } cout << sum << "\n"; } if (flag == 1) { index = int(upper_bound(height.begin(), height.end(), plane[i]) - height.begin()); cout << (index * (index + 1)) / 2 << "\n"; } } }
#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...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...