답안 #1060248

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1060248 2024-08-15T12:01:31 Z anango Gift Exchange (JOI24_ho_t4) C++17
50 / 100
2500 ms 11444 KB
#include <bits/stdc++.h>
#define int long long
using namespace std;
int INF = 1LL<<30;



signed main() {
    int local = 0;
    if (local) {
        // for getting input from input.txt
        freopen("input.txt", "r", stdin);
        // for writing output to output.txt
        freopen("output.txt", "w", stdout);
    }
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n; cin >> n;
    vector<int> ar(n); for (int i=0; i<n; i++) cin >> ar[i];
    vector<int> br(n); for (int i=0; i<n; i++) cin >> br[i];
    /*for (int i=0; i<n; i++) {
        ar[i]--; br[i]--;
    }*/
    int q; cin >> q;
    while (q--) {
        int l,r; cin >> l >> r; l--; r--;
        vector<pair<int,int>> endpoints;
        for (int i=l; i<=r; i++) {
            endpoints.push_back({ar[i],-(i+1)});
            endpoints.push_back({br[i],(i+1)});
        }
        sort(endpoints.begin(), endpoints.end());
        int fail = 0;
        int ct = 0;
        for (int i=0; i<endpoints.size(); i++) {
            if (endpoints[i].second<0) ct--;
            else ct++;
            //cout << i <<" " << endpoints[i].first <<" " << endpoints[i].second <<" " << ct << endl;
            if (ct==0 && i!=0 && endpoints[i].second+endpoints[i-1].second==0) {
                fail=1;
            }
        }
        if (fail) {
            cout << "No" << endl;
        }
        else {
            cout << "Yes" << endl;
        }
    }
    
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:35:24: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   35 |         for (int i=0; i<endpoints.size(); i++) {
      |                       ~^~~~~~~~~~~~~~~~~
Main.cpp:12:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   12 |         freopen("input.txt", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:14:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   14 |         freopen("output.txt", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 0 ms 456 KB Output is correct
23 Correct 0 ms 448 KB Output is correct
24 Correct 0 ms 456 KB Output is correct
25 Correct 0 ms 452 KB Output is correct
26 Correct 0 ms 348 KB Output is correct
27 Correct 0 ms 348 KB Output is correct
28 Correct 0 ms 348 KB Output is correct
29 Correct 0 ms 348 KB Output is correct
30 Correct 0 ms 348 KB Output is correct
31 Correct 0 ms 348 KB Output is correct
32 Correct 0 ms 460 KB Output is correct
33 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 29 ms 9428 KB Output is correct
5 Correct 28 ms 7628 KB Output is correct
6 Correct 37 ms 7636 KB Output is correct
7 Correct 35 ms 8916 KB Output is correct
8 Correct 29 ms 9168 KB Output is correct
9 Correct 28 ms 9172 KB Output is correct
10 Correct 28 ms 9172 KB Output is correct
11 Correct 28 ms 7892 KB Output is correct
12 Correct 28 ms 9420 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 0 ms 456 KB Output is correct
23 Correct 0 ms 448 KB Output is correct
24 Correct 0 ms 456 KB Output is correct
25 Correct 0 ms 452 KB Output is correct
26 Correct 0 ms 348 KB Output is correct
27 Correct 0 ms 348 KB Output is correct
28 Correct 0 ms 348 KB Output is correct
29 Correct 0 ms 348 KB Output is correct
30 Correct 0 ms 348 KB Output is correct
31 Correct 0 ms 348 KB Output is correct
32 Correct 0 ms 460 KB Output is correct
33 Correct 0 ms 348 KB Output is correct
34 Correct 0 ms 348 KB Output is correct
35 Correct 0 ms 348 KB Output is correct
36 Correct 0 ms 348 KB Output is correct
37 Correct 29 ms 9428 KB Output is correct
38 Correct 28 ms 7628 KB Output is correct
39 Correct 37 ms 7636 KB Output is correct
40 Correct 35 ms 8916 KB Output is correct
41 Correct 29 ms 9168 KB Output is correct
42 Correct 28 ms 9172 KB Output is correct
43 Correct 28 ms 9172 KB Output is correct
44 Correct 28 ms 7892 KB Output is correct
45 Correct 28 ms 9420 KB Output is correct
46 Correct 58 ms 6108 KB Output is correct
47 Correct 50 ms 7036 KB Output is correct
48 Correct 20 ms 4564 KB Output is correct
49 Correct 39 ms 7284 KB Output is correct
50 Correct 75 ms 11380 KB Output is correct
51 Correct 60 ms 10416 KB Output is correct
52 Correct 11 ms 2392 KB Output is correct
53 Correct 18 ms 4312 KB Output is correct
54 Correct 176 ms 10532 KB Output is correct
55 Correct 177 ms 10732 KB Output is correct
56 Correct 72 ms 10416 KB Output is correct
57 Correct 63 ms 11444 KB Output is correct
58 Correct 55 ms 8132 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 448 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Execution timed out 2594 ms 9712 KB Time limit exceeded
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 448 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Execution timed out 2594 ms 9712 KB Time limit exceeded
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 0 ms 456 KB Output is correct
23 Correct 0 ms 448 KB Output is correct
24 Correct 0 ms 456 KB Output is correct
25 Correct 0 ms 452 KB Output is correct
26 Correct 0 ms 348 KB Output is correct
27 Correct 0 ms 348 KB Output is correct
28 Correct 0 ms 348 KB Output is correct
29 Correct 0 ms 348 KB Output is correct
30 Correct 0 ms 348 KB Output is correct
31 Correct 0 ms 348 KB Output is correct
32 Correct 0 ms 460 KB Output is correct
33 Correct 0 ms 348 KB Output is correct
34 Correct 0 ms 348 KB Output is correct
35 Correct 0 ms 348 KB Output is correct
36 Correct 0 ms 348 KB Output is correct
37 Correct 29 ms 9428 KB Output is correct
38 Correct 28 ms 7628 KB Output is correct
39 Correct 37 ms 7636 KB Output is correct
40 Correct 35 ms 8916 KB Output is correct
41 Correct 29 ms 9168 KB Output is correct
42 Correct 28 ms 9172 KB Output is correct
43 Correct 28 ms 9172 KB Output is correct
44 Correct 28 ms 7892 KB Output is correct
45 Correct 28 ms 9420 KB Output is correct
46 Correct 58 ms 6108 KB Output is correct
47 Correct 50 ms 7036 KB Output is correct
48 Correct 20 ms 4564 KB Output is correct
49 Correct 39 ms 7284 KB Output is correct
50 Correct 75 ms 11380 KB Output is correct
51 Correct 60 ms 10416 KB Output is correct
52 Correct 11 ms 2392 KB Output is correct
53 Correct 18 ms 4312 KB Output is correct
54 Correct 176 ms 10532 KB Output is correct
55 Correct 177 ms 10732 KB Output is correct
56 Correct 72 ms 10416 KB Output is correct
57 Correct 63 ms 11444 KB Output is correct
58 Correct 55 ms 8132 KB Output is correct
59 Correct 0 ms 448 KB Output is correct
60 Correct 0 ms 348 KB Output is correct
61 Correct 0 ms 348 KB Output is correct
62 Execution timed out 2594 ms 9712 KB Time limit exceeded
63 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 0 ms 456 KB Output is correct
23 Correct 0 ms 448 KB Output is correct
24 Correct 0 ms 456 KB Output is correct
25 Correct 0 ms 452 KB Output is correct
26 Correct 0 ms 348 KB Output is correct
27 Correct 0 ms 348 KB Output is correct
28 Correct 0 ms 348 KB Output is correct
29 Correct 0 ms 348 KB Output is correct
30 Correct 0 ms 348 KB Output is correct
31 Correct 0 ms 348 KB Output is correct
32 Correct 0 ms 460 KB Output is correct
33 Correct 0 ms 348 KB Output is correct
34 Correct 0 ms 348 KB Output is correct
35 Correct 0 ms 348 KB Output is correct
36 Correct 0 ms 348 KB Output is correct
37 Correct 29 ms 9428 KB Output is correct
38 Correct 28 ms 7628 KB Output is correct
39 Correct 37 ms 7636 KB Output is correct
40 Correct 35 ms 8916 KB Output is correct
41 Correct 29 ms 9168 KB Output is correct
42 Correct 28 ms 9172 KB Output is correct
43 Correct 28 ms 9172 KB Output is correct
44 Correct 28 ms 7892 KB Output is correct
45 Correct 28 ms 9420 KB Output is correct
46 Correct 58 ms 6108 KB Output is correct
47 Correct 50 ms 7036 KB Output is correct
48 Correct 20 ms 4564 KB Output is correct
49 Correct 39 ms 7284 KB Output is correct
50 Correct 75 ms 11380 KB Output is correct
51 Correct 60 ms 10416 KB Output is correct
52 Correct 11 ms 2392 KB Output is correct
53 Correct 18 ms 4312 KB Output is correct
54 Correct 176 ms 10532 KB Output is correct
55 Correct 177 ms 10732 KB Output is correct
56 Correct 72 ms 10416 KB Output is correct
57 Correct 63 ms 11444 KB Output is correct
58 Correct 55 ms 8132 KB Output is correct
59 Correct 0 ms 448 KB Output is correct
60 Correct 0 ms 348 KB Output is correct
61 Correct 0 ms 348 KB Output is correct
62 Execution timed out 2594 ms 9712 KB Time limit exceeded
63 Halted 0 ms 0 KB -