Submission #320933

# Submission time Handle Problem Language Result Execution time Memory
320933 2020-11-10T09:35:55 Z strawberry2005 Pilot (NOI19_pilot) C++14
55 / 100
1000 ms 1816 KB
#include<bits/stdc++.h>
#define deb(x) cout<<#x<<": "<<x<<endl

using namespace std;

int main(){

    long long n,q;
    cin>>n>>q;
    long long heights[n],planes[q];
    for(int i=0;i<n;i++) cin>>heights[i];
    for(int i=0;i<q;i++) cin>>planes[i];


    if(is_sorted(heights,heights+n)){
        //cout<<"HELLO\n";
        for(int i=0;i<q;i++){
            long long reach_height=planes[i];
            long long ans=0;
            for(int j=0;j<n;j++){
                long long f=upper_bound(heights,heights+n,planes[i])-heights;
                ans=f*(f+1)/2;
            
            }
            cout<<ans<<endl;
        }
    }
    
    else{

        for(int i=0;i<q;i++){
            long long reach_height=planes[i];
            long long count=0,ans=0;
            for(int j=0;j<n;j++){
                if(heights[j]<=reach_height) count++;
                else{
                    ans+=count*(count+1)/2;
                    count=0;
                    
                }
            
            }
            if(count!=0) ans+=count*(count+1)/2;
            cout<<ans<<endl;
        }
    }


    return(0);
}

Compilation message

pilot.cpp: In function 'int main()':
pilot.cpp:18:23: warning: unused variable 'reach_height' [-Wunused-variable]
   18 |             long long reach_height=planes[i];
      |                       ^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 0 ms 364 KB Output is correct
3 Correct 0 ms 364 KB Output is correct
4 Correct 0 ms 364 KB Output is correct
5 Correct 0 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 0 ms 364 KB Output is correct
8 Correct 0 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 0 ms 364 KB Output is correct
3 Correct 0 ms 364 KB Output is correct
4 Correct 0 ms 364 KB Output is correct
5 Correct 0 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 0 ms 364 KB Output is correct
8 Correct 0 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 384 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 0 ms 364 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 0 ms 364 KB Output is correct
3 Correct 0 ms 364 KB Output is correct
4 Correct 0 ms 364 KB Output is correct
5 Correct 0 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 0 ms 364 KB Output is correct
8 Correct 0 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 384 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 0 ms 364 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
16 Correct 1 ms 364 KB Output is correct
17 Correct 1 ms 364 KB Output is correct
18 Correct 1 ms 364 KB Output is correct
19 Correct 2 ms 364 KB Output is correct
20 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 0 ms 364 KB Output is correct
3 Correct 0 ms 364 KB Output is correct
4 Correct 0 ms 364 KB Output is correct
5 Correct 0 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 0 ms 364 KB Output is correct
8 Correct 0 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 384 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 0 ms 364 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
16 Correct 1 ms 364 KB Output is correct
17 Correct 1 ms 364 KB Output is correct
18 Correct 1 ms 364 KB Output is correct
19 Correct 2 ms 364 KB Output is correct
20 Correct 1 ms 364 KB Output is correct
21 Correct 4 ms 384 KB Output is correct
22 Correct 5 ms 364 KB Output is correct
23 Correct 4 ms 364 KB Output is correct
24 Correct 6 ms 364 KB Output is correct
25 Correct 4 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 29 ms 1004 KB Output is correct
2 Correct 32 ms 1124 KB Output is correct
3 Correct 27 ms 1004 KB Output is correct
4 Correct 29 ms 996 KB Output is correct
5 Correct 27 ms 1004 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 1063 ms 1816 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1035 ms 1764 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 0 ms 364 KB Output is correct
3 Correct 0 ms 364 KB Output is correct
4 Correct 0 ms 364 KB Output is correct
5 Correct 0 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 0 ms 364 KB Output is correct
8 Correct 0 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 29 ms 1004 KB Output is correct
12 Correct 32 ms 1124 KB Output is correct
13 Correct 27 ms 1004 KB Output is correct
14 Correct 29 ms 996 KB Output is correct
15 Correct 27 ms 1004 KB Output is correct
16 Correct 27 ms 996 KB Output is correct
17 Correct 31 ms 1124 KB Output is correct
18 Correct 31 ms 1124 KB Output is correct
19 Correct 31 ms 1004 KB Output is correct
20 Correct 31 ms 1004 KB Output is correct
21 Correct 26 ms 1004 KB Output is correct
22 Correct 30 ms 992 KB Output is correct
23 Correct 29 ms 1124 KB Output is correct
24 Correct 29 ms 1004 KB Output is correct
25 Correct 31 ms 1000 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 0 ms 364 KB Output is correct
3 Correct 0 ms 364 KB Output is correct
4 Correct 0 ms 364 KB Output is correct
5 Correct 0 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 0 ms 364 KB Output is correct
8 Correct 0 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 384 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 0 ms 364 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
16 Correct 1 ms 364 KB Output is correct
17 Correct 1 ms 364 KB Output is correct
18 Correct 1 ms 364 KB Output is correct
19 Correct 2 ms 364 KB Output is correct
20 Correct 1 ms 364 KB Output is correct
21 Correct 4 ms 384 KB Output is correct
22 Correct 5 ms 364 KB Output is correct
23 Correct 4 ms 364 KB Output is correct
24 Correct 6 ms 364 KB Output is correct
25 Correct 4 ms 364 KB Output is correct
26 Correct 29 ms 1004 KB Output is correct
27 Correct 32 ms 1124 KB Output is correct
28 Correct 27 ms 1004 KB Output is correct
29 Correct 29 ms 996 KB Output is correct
30 Correct 27 ms 1004 KB Output is correct
31 Execution timed out 1063 ms 1816 KB Time limit exceeded
32 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 0 ms 364 KB Output is correct
3 Correct 0 ms 364 KB Output is correct
4 Correct 0 ms 364 KB Output is correct
5 Correct 0 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 0 ms 364 KB Output is correct
8 Correct 0 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 384 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 0 ms 364 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
16 Correct 1 ms 364 KB Output is correct
17 Correct 1 ms 364 KB Output is correct
18 Correct 1 ms 364 KB Output is correct
19 Correct 2 ms 364 KB Output is correct
20 Correct 1 ms 364 KB Output is correct
21 Correct 4 ms 384 KB Output is correct
22 Correct 5 ms 364 KB Output is correct
23 Correct 4 ms 364 KB Output is correct
24 Correct 6 ms 364 KB Output is correct
25 Correct 4 ms 364 KB Output is correct
26 Correct 29 ms 1004 KB Output is correct
27 Correct 32 ms 1124 KB Output is correct
28 Correct 27 ms 1004 KB Output is correct
29 Correct 29 ms 996 KB Output is correct
30 Correct 27 ms 1004 KB Output is correct
31 Execution timed out 1063 ms 1816 KB Time limit exceeded
32 Halted 0 ms 0 KB -