답안 #320928

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
320928 2020-11-10T09:18:50 Z strawberry2005 Pilot (NOI19_pilot) C++14
55 / 100
1000 ms 2148 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+1],planes[q];
    for(int i=0;i<n;i++) cin>>heights[i];
    for(int i=0;i<q;i++) cin>>planes[i];
    heights[n]=1e9;

    if(is_sorted(heights,heights+n+1)){
        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+1;j++){
                long long f=upper_bound(heights,heights+n+1,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+1;j++){
                if(heights[j]<=reach_height) count++;
                else{
                    ans+=count*(count+1)/2;
                    count=0;
                    
                }
            
            }
            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];
      |                       ^~~~~~~~~~~~
pilot.cpp:18:23: warning: unused variable 'count' [-Wunused-variable]
   18 |             long long count=0,ans=0;
      |                       ^~~~~
# 결과 실행 시간 메모리 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 0 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 0 ms 364 KB Output is correct
9 Correct 0 ms 364 KB Output is correct
10 Correct 1 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 0 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 0 ms 364 KB Output is correct
9 Correct 0 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 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 1 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 0 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 0 ms 364 KB Output is correct
9 Correct 0 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 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 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
# 결과 실행 시간 메모리 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 0 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 0 ms 364 KB Output is correct
9 Correct 0 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 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 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 5 ms 364 KB Output is correct
22 Correct 6 ms 364 KB Output is correct
23 Correct 5 ms 364 KB Output is correct
24 Correct 6 ms 364 KB Output is correct
25 Correct 5 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 28 ms 1252 KB Output is correct
2 Correct 36 ms 1380 KB Output is correct
3 Correct 27 ms 1124 KB Output is correct
4 Correct 29 ms 1400 KB Output is correct
5 Correct 27 ms 1260 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1037 ms 2144 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1041 ms 2148 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 0 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 0 ms 364 KB Output is correct
9 Correct 0 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 28 ms 1252 KB Output is correct
12 Correct 36 ms 1380 KB Output is correct
13 Correct 27 ms 1124 KB Output is correct
14 Correct 29 ms 1400 KB Output is correct
15 Correct 27 ms 1260 KB Output is correct
16 Correct 31 ms 1124 KB Output is correct
17 Correct 32 ms 1252 KB Output is correct
18 Correct 33 ms 1252 KB Output is correct
19 Correct 26 ms 1124 KB Output is correct
20 Correct 31 ms 1252 KB Output is correct
21 Correct 27 ms 1124 KB Output is correct
22 Correct 36 ms 1124 KB Output is correct
23 Correct 29 ms 1124 KB Output is correct
24 Correct 31 ms 1132 KB Output is correct
25 Correct 28 ms 1124 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 0 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 0 ms 364 KB Output is correct
9 Correct 0 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 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 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 5 ms 364 KB Output is correct
22 Correct 6 ms 364 KB Output is correct
23 Correct 5 ms 364 KB Output is correct
24 Correct 6 ms 364 KB Output is correct
25 Correct 5 ms 364 KB Output is correct
26 Correct 28 ms 1252 KB Output is correct
27 Correct 36 ms 1380 KB Output is correct
28 Correct 27 ms 1124 KB Output is correct
29 Correct 29 ms 1400 KB Output is correct
30 Correct 27 ms 1260 KB Output is correct
31 Execution timed out 1037 ms 2144 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 0 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 0 ms 364 KB Output is correct
9 Correct 0 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 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 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 5 ms 364 KB Output is correct
22 Correct 6 ms 364 KB Output is correct
23 Correct 5 ms 364 KB Output is correct
24 Correct 6 ms 364 KB Output is correct
25 Correct 5 ms 364 KB Output is correct
26 Correct 28 ms 1252 KB Output is correct
27 Correct 36 ms 1380 KB Output is correct
28 Correct 27 ms 1124 KB Output is correct
29 Correct 29 ms 1400 KB Output is correct
30 Correct 27 ms 1260 KB Output is correct
31 Execution timed out 1037 ms 2144 KB Time limit exceeded
32 Halted 0 ms 0 KB -