Submission #493992

# Submission time Handle Problem Language Result Execution time Memory
493992 2021-12-13T17:07:06 Z Hades504 Pilot (NOI19_pilot) C++14
55 / 100
1000 ms 3236 KB
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define endl "\n"

signed main() {
  ios_base::sync_with_stdio(false); cin.tie(NULL);
  int n,q;
  cin>>n>>q;
  vector<int>h(n),y(q);
  for(int i=0;i<n;i++){
    cin>>h[i];
  }
  for(int i=0;i<q;i++){
    cin>>y[i];
  }
  for(int i=0;i<q;i++){
    int a = y[i];
    int x =0;
    int sum=0;
    for(int j=0;j<n;j++){
      if(h[j]>y[i]){
        int diff=j-x;
        int ans=(diff*(diff-1))/2+diff;
        sum+=ans;
        x=j+1;
        
      }
      else if(j==n-1){
        int diff=j-x+1;
        int ans=(diff*(diff-1))/2+diff;
        sum+=ans;
      }
    }
    cout<<sum<<endl;
  }
  
  return 0;
}

Compilation message

pilot.cpp: In function 'int main()':
pilot.cpp:18:9: warning: unused variable 'a' [-Wunused-variable]
   18 |     int a = y[i];
      |         ^
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 316 KB Output is correct
3 Correct 1 ms 312 KB Output is correct
4 Correct 1 ms 208 KB Output is correct
5 Correct 0 ms 208 KB Output is correct
6 Correct 1 ms 208 KB Output is correct
7 Correct 1 ms 208 KB Output is correct
8 Correct 1 ms 208 KB Output is correct
9 Correct 0 ms 208 KB Output is correct
10 Correct 0 ms 208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 316 KB Output is correct
3 Correct 1 ms 312 KB Output is correct
4 Correct 1 ms 208 KB Output is correct
5 Correct 0 ms 208 KB Output is correct
6 Correct 1 ms 208 KB Output is correct
7 Correct 1 ms 208 KB Output is correct
8 Correct 1 ms 208 KB Output is correct
9 Correct 0 ms 208 KB Output is correct
10 Correct 0 ms 208 KB Output is correct
11 Correct 0 ms 208 KB Output is correct
12 Correct 0 ms 312 KB Output is correct
13 Correct 1 ms 208 KB Output is correct
14 Correct 1 ms 312 KB Output is correct
15 Correct 0 ms 208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 316 KB Output is correct
3 Correct 1 ms 312 KB Output is correct
4 Correct 1 ms 208 KB Output is correct
5 Correct 0 ms 208 KB Output is correct
6 Correct 1 ms 208 KB Output is correct
7 Correct 1 ms 208 KB Output is correct
8 Correct 1 ms 208 KB Output is correct
9 Correct 0 ms 208 KB Output is correct
10 Correct 0 ms 208 KB Output is correct
11 Correct 0 ms 208 KB Output is correct
12 Correct 0 ms 312 KB Output is correct
13 Correct 1 ms 208 KB Output is correct
14 Correct 1 ms 312 KB Output is correct
15 Correct 0 ms 208 KB Output is correct
16 Correct 1 ms 208 KB Output is correct
17 Correct 1 ms 208 KB Output is correct
18 Correct 1 ms 208 KB Output is correct
19 Correct 1 ms 208 KB Output is correct
20 Correct 1 ms 208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 316 KB Output is correct
3 Correct 1 ms 312 KB Output is correct
4 Correct 1 ms 208 KB Output is correct
5 Correct 0 ms 208 KB Output is correct
6 Correct 1 ms 208 KB Output is correct
7 Correct 1 ms 208 KB Output is correct
8 Correct 1 ms 208 KB Output is correct
9 Correct 0 ms 208 KB Output is correct
10 Correct 0 ms 208 KB Output is correct
11 Correct 0 ms 208 KB Output is correct
12 Correct 0 ms 312 KB Output is correct
13 Correct 1 ms 208 KB Output is correct
14 Correct 1 ms 312 KB Output is correct
15 Correct 0 ms 208 KB Output is correct
16 Correct 1 ms 208 KB Output is correct
17 Correct 1 ms 208 KB Output is correct
18 Correct 1 ms 208 KB Output is correct
19 Correct 1 ms 208 KB Output is correct
20 Correct 1 ms 208 KB Output is correct
21 Correct 2 ms 336 KB Output is correct
22 Correct 3 ms 336 KB Output is correct
23 Correct 2 ms 336 KB Output is correct
24 Correct 3 ms 336 KB Output is correct
25 Correct 2 ms 336 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 1612 KB Output is correct
2 Correct 10 ms 1744 KB Output is correct
3 Correct 8 ms 1616 KB Output is correct
4 Correct 7 ms 1616 KB Output is correct
5 Correct 7 ms 1548 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 1091 ms 2996 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1081 ms 3236 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 316 KB Output is correct
3 Correct 1 ms 312 KB Output is correct
4 Correct 1 ms 208 KB Output is correct
5 Correct 0 ms 208 KB Output is correct
6 Correct 1 ms 208 KB Output is correct
7 Correct 1 ms 208 KB Output is correct
8 Correct 1 ms 208 KB Output is correct
9 Correct 0 ms 208 KB Output is correct
10 Correct 0 ms 208 KB Output is correct
11 Correct 7 ms 1612 KB Output is correct
12 Correct 10 ms 1744 KB Output is correct
13 Correct 8 ms 1616 KB Output is correct
14 Correct 7 ms 1616 KB Output is correct
15 Correct 7 ms 1548 KB Output is correct
16 Correct 8 ms 1488 KB Output is correct
17 Correct 10 ms 1720 KB Output is correct
18 Correct 9 ms 1744 KB Output is correct
19 Correct 8 ms 1488 KB Output is correct
20 Correct 9 ms 1616 KB Output is correct
21 Correct 8 ms 1488 KB Output is correct
22 Correct 10 ms 1616 KB Output is correct
23 Correct 12 ms 1616 KB Output is correct
24 Correct 8 ms 1616 KB Output is correct
25 Correct 11 ms 1616 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 316 KB Output is correct
3 Correct 1 ms 312 KB Output is correct
4 Correct 1 ms 208 KB Output is correct
5 Correct 0 ms 208 KB Output is correct
6 Correct 1 ms 208 KB Output is correct
7 Correct 1 ms 208 KB Output is correct
8 Correct 1 ms 208 KB Output is correct
9 Correct 0 ms 208 KB Output is correct
10 Correct 0 ms 208 KB Output is correct
11 Correct 0 ms 208 KB Output is correct
12 Correct 0 ms 312 KB Output is correct
13 Correct 1 ms 208 KB Output is correct
14 Correct 1 ms 312 KB Output is correct
15 Correct 0 ms 208 KB Output is correct
16 Correct 1 ms 208 KB Output is correct
17 Correct 1 ms 208 KB Output is correct
18 Correct 1 ms 208 KB Output is correct
19 Correct 1 ms 208 KB Output is correct
20 Correct 1 ms 208 KB Output is correct
21 Correct 2 ms 336 KB Output is correct
22 Correct 3 ms 336 KB Output is correct
23 Correct 2 ms 336 KB Output is correct
24 Correct 3 ms 336 KB Output is correct
25 Correct 2 ms 336 KB Output is correct
26 Correct 7 ms 1612 KB Output is correct
27 Correct 10 ms 1744 KB Output is correct
28 Correct 8 ms 1616 KB Output is correct
29 Correct 7 ms 1616 KB Output is correct
30 Correct 7 ms 1548 KB Output is correct
31 Execution timed out 1091 ms 2996 KB Time limit exceeded
32 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 316 KB Output is correct
3 Correct 1 ms 312 KB Output is correct
4 Correct 1 ms 208 KB Output is correct
5 Correct 0 ms 208 KB Output is correct
6 Correct 1 ms 208 KB Output is correct
7 Correct 1 ms 208 KB Output is correct
8 Correct 1 ms 208 KB Output is correct
9 Correct 0 ms 208 KB Output is correct
10 Correct 0 ms 208 KB Output is correct
11 Correct 0 ms 208 KB Output is correct
12 Correct 0 ms 312 KB Output is correct
13 Correct 1 ms 208 KB Output is correct
14 Correct 1 ms 312 KB Output is correct
15 Correct 0 ms 208 KB Output is correct
16 Correct 1 ms 208 KB Output is correct
17 Correct 1 ms 208 KB Output is correct
18 Correct 1 ms 208 KB Output is correct
19 Correct 1 ms 208 KB Output is correct
20 Correct 1 ms 208 KB Output is correct
21 Correct 2 ms 336 KB Output is correct
22 Correct 3 ms 336 KB Output is correct
23 Correct 2 ms 336 KB Output is correct
24 Correct 3 ms 336 KB Output is correct
25 Correct 2 ms 336 KB Output is correct
26 Correct 7 ms 1612 KB Output is correct
27 Correct 10 ms 1744 KB Output is correct
28 Correct 8 ms 1616 KB Output is correct
29 Correct 7 ms 1616 KB Output is correct
30 Correct 7 ms 1548 KB Output is correct
31 Execution timed out 1091 ms 2996 KB Time limit exceeded
32 Halted 0 ms 0 KB -