답안 #320932

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
320932 2020-11-10T09:32:52 Z strawberry2005 Pilot (NOI19_pilot) C++14
55 / 100
1000 ms 1892 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)){
        for(int i=0;i<q;i++){
            long long reach_height=planes[i];
            long long ans=0;
            for(int j=0;j<n+1;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:17:23: warning: unused variable 'reach_height' [-Wunused-variable]
   17 |             long long reach_height=planes[i];
      |                       ^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 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 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 360 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 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 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 360 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 0 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 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 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 360 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 0 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 1 ms 364 KB Output is correct
20 Correct 1 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 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 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 360 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 0 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 1 ms 364 KB Output is correct
20 Correct 1 ms 384 KB Output is correct
21 Correct 4 ms 364 KB Output is correct
22 Correct 5 ms 372 KB Output is correct
23 Correct 5 ms 364 KB Output is correct
24 Correct 5 ms 364 KB Output is correct
25 Correct 4 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 28 ms 996 KB Output is correct
2 Correct 31 ms 1124 KB Output is correct
3 Correct 28 ms 1004 KB Output is correct
4 Correct 28 ms 996 KB Output is correct
5 Correct 27 ms 996 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1051 ms 1892 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1056 ms 1828 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 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 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 360 KB Output is correct
11 Correct 28 ms 996 KB Output is correct
12 Correct 31 ms 1124 KB Output is correct
13 Correct 28 ms 1004 KB Output is correct
14 Correct 28 ms 996 KB Output is correct
15 Correct 27 ms 996 KB Output is correct
16 Correct 27 ms 996 KB Output is correct
17 Correct 32 ms 1124 KB Output is correct
18 Correct 31 ms 1124 KB Output is correct
19 Correct 26 ms 996 KB Output is correct
20 Correct 31 ms 996 KB Output is correct
21 Correct 26 ms 1000 KB Output is correct
22 Correct 30 ms 1004 KB Output is correct
23 Correct 29 ms 1252 KB Output is correct
24 Correct 29 ms 1004 KB Output is correct
25 Correct 28 ms 1004 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 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 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 360 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 0 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 1 ms 364 KB Output is correct
20 Correct 1 ms 384 KB Output is correct
21 Correct 4 ms 364 KB Output is correct
22 Correct 5 ms 372 KB Output is correct
23 Correct 5 ms 364 KB Output is correct
24 Correct 5 ms 364 KB Output is correct
25 Correct 4 ms 364 KB Output is correct
26 Correct 28 ms 996 KB Output is correct
27 Correct 31 ms 1124 KB Output is correct
28 Correct 28 ms 1004 KB Output is correct
29 Correct 28 ms 996 KB Output is correct
30 Correct 27 ms 996 KB Output is correct
31 Execution timed out 1051 ms 1892 KB Time limit exceeded
32 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 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 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 360 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 0 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 1 ms 364 KB Output is correct
20 Correct 1 ms 384 KB Output is correct
21 Correct 4 ms 364 KB Output is correct
22 Correct 5 ms 372 KB Output is correct
23 Correct 5 ms 364 KB Output is correct
24 Correct 5 ms 364 KB Output is correct
25 Correct 4 ms 364 KB Output is correct
26 Correct 28 ms 996 KB Output is correct
27 Correct 31 ms 1124 KB Output is correct
28 Correct 28 ms 1004 KB Output is correct
29 Correct 28 ms 996 KB Output is correct
30 Correct 27 ms 996 KB Output is correct
31 Execution timed out 1051 ms 1892 KB Time limit exceeded
32 Halted 0 ms 0 KB -