Submission #572422

# Submission time Handle Problem Language Result Execution time Memory
572422 2022-06-04T10:55:16 Z PiejanVDC Pilot (NOI19_pilot) C++17
78 / 100
1000 ms 2976 KB
#include <bits/stdc++.h>
using namespace std;

signed main() {
  int n,q; cin>>n>>q;
  vector<int>v(n);
  for(auto &z : v) {
    cin>>z;
  }
  bool inc = 1;
  for(int i = 0 ; i < n-1 ; i++) {
    if(v[i] > v[i+1])
      inc = 0;
  }
  v.push_back(INT_MAX);

  auto solve = [&] (int h) -> void {
    long long p = n;
    int l = 0, r = n;
    while(l <= r) {
      int mid = (l+r)/2;
      if(v[mid] > h) {
        p = mid, r = mid-1;
      } else l = mid+1;
    }
    cout << (p * (p+1))/2 << '\n';
  };

  while(q--) {
    int h; cin>>h;
    if(h == (int)1e6) {
      long long x = n;
      cout << (x * (x+1))/2 << '\n';
      continue;
    }
    if(inc) {
      solve(h);
      continue;
    }
    long long cnt = 0;
    long long ans = 0;
    for(int i = 0 ; i <= n ; i++) {
      if(v[i] <= h) {
        cnt++;
      } else {
        ans += (cnt * (cnt+1))/2;
        cnt = 0;
      }
    }
    cout << ans << '\n';
  }
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 304 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 304 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 300 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 304 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 300 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 304 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 300 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 304 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 300 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 304 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 300 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 3 ms 212 KB Output is correct
22 Correct 3 ms 308 KB Output is correct
23 Correct 3 ms 424 KB Output is correct
24 Correct 5 ms 328 KB Output is correct
25 Correct 4 ms 304 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 34 ms 1156 KB Output is correct
2 Correct 36 ms 1124 KB Output is correct
3 Correct 26 ms 1080 KB Output is correct
4 Correct 31 ms 1052 KB Output is correct
5 Correct 27 ms 1120 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 193 ms 1976 KB Output is correct
2 Correct 208 ms 2804 KB Output is correct
3 Correct 209 ms 2788 KB Output is correct
4 Correct 188 ms 2804 KB Output is correct
5 Correct 187 ms 2792 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 198 ms 2020 KB Output is correct
2 Correct 208 ms 2784 KB Output is correct
3 Correct 194 ms 2856 KB Output is correct
4 Correct 210 ms 2904 KB Output is correct
5 Correct 223 ms 2976 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 304 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 34 ms 1156 KB Output is correct
12 Correct 36 ms 1124 KB Output is correct
13 Correct 26 ms 1080 KB Output is correct
14 Correct 31 ms 1052 KB Output is correct
15 Correct 27 ms 1120 KB Output is correct
16 Correct 25 ms 1072 KB Output is correct
17 Correct 33 ms 1100 KB Output is correct
18 Correct 34 ms 1220 KB Output is correct
19 Correct 31 ms 1132 KB Output is correct
20 Correct 31 ms 1088 KB Output is correct
21 Correct 27 ms 1176 KB Output is correct
22 Correct 32 ms 1152 KB Output is correct
23 Correct 33 ms 1200 KB Output is correct
24 Correct 28 ms 1052 KB Output is correct
25 Correct 27 ms 1088 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 304 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 300 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 304 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 300 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 3 ms 212 KB Output is correct
22 Correct 3 ms 308 KB Output is correct
23 Correct 3 ms 424 KB Output is correct
24 Correct 5 ms 328 KB Output is correct
25 Correct 4 ms 304 KB Output is correct
26 Correct 34 ms 1156 KB Output is correct
27 Correct 36 ms 1124 KB Output is correct
28 Correct 26 ms 1080 KB Output is correct
29 Correct 31 ms 1052 KB Output is correct
30 Correct 27 ms 1120 KB Output is correct
31 Correct 193 ms 1976 KB Output is correct
32 Correct 208 ms 2804 KB Output is correct
33 Correct 209 ms 2788 KB Output is correct
34 Correct 188 ms 2804 KB Output is correct
35 Correct 187 ms 2792 KB Output is correct
36 Correct 198 ms 2020 KB Output is correct
37 Correct 208 ms 2784 KB Output is correct
38 Correct 194 ms 2856 KB Output is correct
39 Correct 210 ms 2904 KB Output is correct
40 Correct 223 ms 2976 KB Output is correct
41 Correct 25 ms 1072 KB Output is correct
42 Correct 33 ms 1100 KB Output is correct
43 Correct 34 ms 1220 KB Output is correct
44 Correct 31 ms 1132 KB Output is correct
45 Correct 31 ms 1088 KB Output is correct
46 Correct 27 ms 1176 KB Output is correct
47 Correct 32 ms 1152 KB Output is correct
48 Correct 33 ms 1200 KB Output is correct
49 Correct 28 ms 1052 KB Output is correct
50 Correct 27 ms 1088 KB Output is correct
51 Execution timed out 1081 ms 1684 KB Time limit exceeded
52 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 304 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 300 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 304 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 300 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 3 ms 212 KB Output is correct
22 Correct 3 ms 308 KB Output is correct
23 Correct 3 ms 424 KB Output is correct
24 Correct 5 ms 328 KB Output is correct
25 Correct 4 ms 304 KB Output is correct
26 Correct 34 ms 1156 KB Output is correct
27 Correct 36 ms 1124 KB Output is correct
28 Correct 26 ms 1080 KB Output is correct
29 Correct 31 ms 1052 KB Output is correct
30 Correct 27 ms 1120 KB Output is correct
31 Correct 193 ms 1976 KB Output is correct
32 Correct 208 ms 2804 KB Output is correct
33 Correct 209 ms 2788 KB Output is correct
34 Correct 188 ms 2804 KB Output is correct
35 Correct 187 ms 2792 KB Output is correct
36 Correct 198 ms 2020 KB Output is correct
37 Correct 208 ms 2784 KB Output is correct
38 Correct 194 ms 2856 KB Output is correct
39 Correct 210 ms 2904 KB Output is correct
40 Correct 223 ms 2976 KB Output is correct
41 Correct 25 ms 1072 KB Output is correct
42 Correct 33 ms 1100 KB Output is correct
43 Correct 34 ms 1220 KB Output is correct
44 Correct 31 ms 1132 KB Output is correct
45 Correct 31 ms 1088 KB Output is correct
46 Correct 27 ms 1176 KB Output is correct
47 Correct 32 ms 1152 KB Output is correct
48 Correct 33 ms 1200 KB Output is correct
49 Correct 28 ms 1052 KB Output is correct
50 Correct 27 ms 1088 KB Output is correct
51 Execution timed out 1081 ms 1684 KB Time limit exceeded
52 Halted 0 ms 0 KB -