답안 #238755

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
238755 2020-06-12T15:59:17 Z Dynamic_Cast Pilot (NOI19_pilot) C++14
78 / 100
1000 ms 3452 KB
//#include <bits/stdc++.h> C++11
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stdio.h>
#include <time.h>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <stack>
#include <queue>
#include <climits>
#include <map>
#include <set>
#include <sstream>
using namespace std;
typedef long long ll;
typedef pair<int, int> pi;
typedef vector<int> vi;
#define PB push_back
#define MP make_pair
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int N, Q, flag, f;
    cin >> N >> Q;
    vi height(N, 0);
    vi plane(Q, 0);
    flag = 1;
    f = 0;
    cin >> height[0];
    for (int i = 1; i < N; i++)
    {
        cin >> height[i];
        if (height[i] < height[i - 1])
        {
            f = 1;
        }
    }
    if (f == 1)
    {
        flag = 0;
    }
    for (int i = 0; i < Q; i++)
    {
        cin >> plane[i];
    }
    if (Q == 1 && plane[0]==1000000)
    {
        flag = 2;
    }
    int num;
    ll sum;
    int index;
    for (int i = 0; i < Q; i++)
    {
        sum = 0;
        if (flag == 0)
        {
            num = 0;
            for (int j = 0; j < N; j++)
            {
                num++;
                if (height[j] > plane[i])
                {
                    sum += ll(ll(num) * (num - 1)) / 2;
                    num = 0;
                }
                else
                {
                    if (j == N - 1)
                    {
                        sum += ll(ll(num) * (num + 1)) / 2;
                    }
                }
            }
            cout << sum << "\n";
        }
        if (flag == 1)
        {
            index = int(upper_bound(height.begin(), height.end(), plane[i]) - height.begin());
            cout << ll(ll(index) * (index + 1)) / 2 << "\n";
        }
        if (flag == 2)
        {
            cout<<ll(ll(N)*(N+1))/2<<"\n";
        }
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 4 ms 384 KB Output is correct
4 Correct 4 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 4 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 4 ms 384 KB Output is correct
9 Correct 4 ms 384 KB Output is correct
10 Correct 4 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 4 ms 384 KB Output is correct
4 Correct 4 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 4 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 4 ms 384 KB Output is correct
9 Correct 4 ms 384 KB Output is correct
10 Correct 4 ms 384 KB Output is correct
11 Correct 4 ms 384 KB Output is correct
12 Correct 4 ms 384 KB Output is correct
13 Correct 4 ms 384 KB Output is correct
14 Correct 4 ms 384 KB Output is correct
15 Correct 4 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 4 ms 384 KB Output is correct
4 Correct 4 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 4 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 4 ms 384 KB Output is correct
9 Correct 4 ms 384 KB Output is correct
10 Correct 4 ms 384 KB Output is correct
11 Correct 4 ms 384 KB Output is correct
12 Correct 4 ms 384 KB Output is correct
13 Correct 4 ms 384 KB Output is correct
14 Correct 4 ms 384 KB Output is correct
15 Correct 4 ms 384 KB Output is correct
16 Correct 5 ms 384 KB Output is correct
17 Correct 5 ms 384 KB Output is correct
18 Correct 5 ms 384 KB Output is correct
19 Correct 5 ms 384 KB Output is correct
20 Correct 5 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 4 ms 384 KB Output is correct
4 Correct 4 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 4 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 4 ms 384 KB Output is correct
9 Correct 4 ms 384 KB Output is correct
10 Correct 4 ms 384 KB Output is correct
11 Correct 4 ms 384 KB Output is correct
12 Correct 4 ms 384 KB Output is correct
13 Correct 4 ms 384 KB Output is correct
14 Correct 4 ms 384 KB Output is correct
15 Correct 4 ms 384 KB Output is correct
16 Correct 5 ms 384 KB Output is correct
17 Correct 5 ms 384 KB Output is correct
18 Correct 5 ms 384 KB Output is correct
19 Correct 5 ms 384 KB Output is correct
20 Correct 5 ms 384 KB Output is correct
21 Correct 6 ms 384 KB Output is correct
22 Correct 7 ms 384 KB Output is correct
23 Correct 7 ms 384 KB Output is correct
24 Correct 7 ms 384 KB Output is correct
25 Correct 6 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 16 ms 768 KB Output is correct
2 Correct 17 ms 1408 KB Output is correct
3 Correct 15 ms 1280 KB Output is correct
4 Correct 15 ms 1280 KB Output is correct
5 Correct 15 ms 1280 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 45 ms 2016 KB Output is correct
2 Correct 46 ms 3320 KB Output is correct
3 Correct 47 ms 3192 KB Output is correct
4 Correct 48 ms 3320 KB Output is correct
5 Correct 44 ms 3192 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 52 ms 2040 KB Output is correct
2 Correct 52 ms 3320 KB Output is correct
3 Correct 51 ms 3320 KB Output is correct
4 Correct 50 ms 3320 KB Output is correct
5 Correct 53 ms 3452 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 4 ms 384 KB Output is correct
4 Correct 4 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 4 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 4 ms 384 KB Output is correct
9 Correct 4 ms 384 KB Output is correct
10 Correct 4 ms 384 KB Output is correct
11 Correct 16 ms 768 KB Output is correct
12 Correct 17 ms 1408 KB Output is correct
13 Correct 15 ms 1280 KB Output is correct
14 Correct 15 ms 1280 KB Output is correct
15 Correct 15 ms 1280 KB Output is correct
16 Correct 15 ms 1280 KB Output is correct
17 Correct 17 ms 1408 KB Output is correct
18 Correct 18 ms 1408 KB Output is correct
19 Correct 15 ms 1280 KB Output is correct
20 Correct 17 ms 1408 KB Output is correct
21 Correct 15 ms 1280 KB Output is correct
22 Correct 16 ms 1280 KB Output is correct
23 Correct 17 ms 1280 KB Output is correct
24 Correct 16 ms 1280 KB Output is correct
25 Correct 16 ms 1280 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 4 ms 384 KB Output is correct
4 Correct 4 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 4 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 4 ms 384 KB Output is correct
9 Correct 4 ms 384 KB Output is correct
10 Correct 4 ms 384 KB Output is correct
11 Correct 4 ms 384 KB Output is correct
12 Correct 4 ms 384 KB Output is correct
13 Correct 4 ms 384 KB Output is correct
14 Correct 4 ms 384 KB Output is correct
15 Correct 4 ms 384 KB Output is correct
16 Correct 5 ms 384 KB Output is correct
17 Correct 5 ms 384 KB Output is correct
18 Correct 5 ms 384 KB Output is correct
19 Correct 5 ms 384 KB Output is correct
20 Correct 5 ms 384 KB Output is correct
21 Correct 6 ms 384 KB Output is correct
22 Correct 7 ms 384 KB Output is correct
23 Correct 7 ms 384 KB Output is correct
24 Correct 7 ms 384 KB Output is correct
25 Correct 6 ms 384 KB Output is correct
26 Correct 16 ms 768 KB Output is correct
27 Correct 17 ms 1408 KB Output is correct
28 Correct 15 ms 1280 KB Output is correct
29 Correct 15 ms 1280 KB Output is correct
30 Correct 15 ms 1280 KB Output is correct
31 Correct 45 ms 2016 KB Output is correct
32 Correct 46 ms 3320 KB Output is correct
33 Correct 47 ms 3192 KB Output is correct
34 Correct 48 ms 3320 KB Output is correct
35 Correct 44 ms 3192 KB Output is correct
36 Correct 52 ms 2040 KB Output is correct
37 Correct 52 ms 3320 KB Output is correct
38 Correct 51 ms 3320 KB Output is correct
39 Correct 50 ms 3320 KB Output is correct
40 Correct 53 ms 3452 KB Output is correct
41 Correct 15 ms 1280 KB Output is correct
42 Correct 17 ms 1408 KB Output is correct
43 Correct 18 ms 1408 KB Output is correct
44 Correct 15 ms 1280 KB Output is correct
45 Correct 17 ms 1408 KB Output is correct
46 Correct 15 ms 1280 KB Output is correct
47 Correct 16 ms 1280 KB Output is correct
48 Correct 17 ms 1280 KB Output is correct
49 Correct 16 ms 1280 KB Output is correct
50 Correct 16 ms 1280 KB Output is correct
51 Execution timed out 1086 ms 2492 KB Time limit exceeded
52 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 4 ms 384 KB Output is correct
4 Correct 4 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 4 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 4 ms 384 KB Output is correct
9 Correct 4 ms 384 KB Output is correct
10 Correct 4 ms 384 KB Output is correct
11 Correct 4 ms 384 KB Output is correct
12 Correct 4 ms 384 KB Output is correct
13 Correct 4 ms 384 KB Output is correct
14 Correct 4 ms 384 KB Output is correct
15 Correct 4 ms 384 KB Output is correct
16 Correct 5 ms 384 KB Output is correct
17 Correct 5 ms 384 KB Output is correct
18 Correct 5 ms 384 KB Output is correct
19 Correct 5 ms 384 KB Output is correct
20 Correct 5 ms 384 KB Output is correct
21 Correct 6 ms 384 KB Output is correct
22 Correct 7 ms 384 KB Output is correct
23 Correct 7 ms 384 KB Output is correct
24 Correct 7 ms 384 KB Output is correct
25 Correct 6 ms 384 KB Output is correct
26 Correct 16 ms 768 KB Output is correct
27 Correct 17 ms 1408 KB Output is correct
28 Correct 15 ms 1280 KB Output is correct
29 Correct 15 ms 1280 KB Output is correct
30 Correct 15 ms 1280 KB Output is correct
31 Correct 45 ms 2016 KB Output is correct
32 Correct 46 ms 3320 KB Output is correct
33 Correct 47 ms 3192 KB Output is correct
34 Correct 48 ms 3320 KB Output is correct
35 Correct 44 ms 3192 KB Output is correct
36 Correct 52 ms 2040 KB Output is correct
37 Correct 52 ms 3320 KB Output is correct
38 Correct 51 ms 3320 KB Output is correct
39 Correct 50 ms 3320 KB Output is correct
40 Correct 53 ms 3452 KB Output is correct
41 Correct 15 ms 1280 KB Output is correct
42 Correct 17 ms 1408 KB Output is correct
43 Correct 18 ms 1408 KB Output is correct
44 Correct 15 ms 1280 KB Output is correct
45 Correct 17 ms 1408 KB Output is correct
46 Correct 15 ms 1280 KB Output is correct
47 Correct 16 ms 1280 KB Output is correct
48 Correct 17 ms 1280 KB Output is correct
49 Correct 16 ms 1280 KB Output is correct
50 Correct 16 ms 1280 KB Output is correct
51 Execution timed out 1086 ms 2492 KB Time limit exceeded
52 Halted 0 ms 0 KB -