QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#606074#8254. Water Journalenze114514AC ✓0ms3684kbC++201.1kb2024-10-02 21:57:342024-10-02 21:57:37

Judging History

你现在查看的是最新测评结果

  • [2024-10-02 21:57:37]
  • 评测
  • 测评结果:AC
  • 用时:0ms
  • 内存:3684kb
  • [2024-10-02 21:57:34]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;

#define pb push_back

const ld pi = 3.14159265358979323846;
const int mod = (int)1e9 + 7;
const ll INF = 1e18;

template<typename T>
T chmax(T a, T b) {
    return a > b ? a : b;
}

template<typename T>
T chmin(T a, T b) {
    return a > b ? b : a;
}

const int N = (int)1e5 + 1, M = N * 2;

void solve(){
    int n, l, r;
    cin >> n >> l >> r;

    int a[n];
    int f1 = 0, f2 = 0;
    for(int i = 0; i < n; i++){
        cin >> a[i];
        if(a[i] == l) f1 = 1;
        if(a[i] == r) f2 = 1;
    }

    if(f1 && f2){
        for(int i = l; i <= r; i++){
            cout << i << endl;
        }
    }
    else if(f1){
        cout << r << endl; 
    }
    else if(f2){
        cout << l << endl; 
    }
    else{
        cout << -1 << endl; 
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(0);

    int t = 1;
    // cin >> t; 

    while(t--){
        solve();
    }

    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3544kb

input:

5 1 5
2
2
4
4

output:

-1

result:

ok single line: '-1'

Test #2:

score: 0
Accepted
time: 0ms
memory: 3556kb

input:

5 1 5
1
2
4
5

output:

1
2
3
4
5

result:

ok 5 lines

Test #3:

score: 0
Accepted
time: 0ms
memory: 3684kb

input:

5 1 5
1
2
3
4

output:

5

result:

ok single line: '5'

Test #4:

score: 0
Accepted
time: 0ms
memory: 3652kb

input:

5 1 5
2
4
5
1

output:

1
2
3
4
5

result:

ok 5 lines

Test #5:

score: 0
Accepted
time: 0ms
memory: 3636kb

input:

5 1 5
3
4
2
1

output:

5

result:

ok single line: '5'

Test #6:

score: 0
Accepted
time: 0ms
memory: 3616kb

input:

8 12 12
12
12
12
12
12
12
12

output:

12

result:

ok single line: '12'

Test #7:

score: 0
Accepted
time: 0ms
memory: 3608kb

input:

2 1 50
24

output:

-1

result:

ok single line: '-1'

Test #8:

score: 0
Accepted
time: 0ms
memory: 3552kb

input:

2 2 49
49

output:

2

result:

ok single line: '2'

Test #9:

score: 0
Accepted
time: 0ms
memory: 3656kb

input:

2 2 49
2

output:

49

result:

ok single line: '49'

Test #10:

score: 0
Accepted
time: 0ms
memory: 3644kb

input:

6 1 45
10
15
20
25
40

output:

-1

result:

ok single line: '-1'