QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#230552#7642. Integer Half-Sumucup-team2112#AC ✓1ms4080kbC++172.3kb2023-10-28 19:31:202023-10-28 19:31:21

Judging History

This is the latest submission verdict.

  • [2023-10-28 19:31:21]
  • Judged
  • Verdict: AC
  • Time: 1ms
  • Memory: 4080kb
  • [2023-10-28 19:31:20]
  • Submitted

answer

#include "bits/stdc++.h"
#define rep(i, a, n) for (auto i = a; i <= (n); ++i)
#define revrep(i, a, n) for (auto i = n; i >= (a); --i)
#define all(a) a.begin(), a.end()
#define sz(a) (int)(a).size()
template<class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, T b) { if (b < a) { a = b; return 1; } return 0; }
using namespace std;

template<class A, class B> string to_string(const pair<A, B> &p);
template<class A, class B, class C> string to_string(const tuple<A, B, C> &p);
template<class A, class B, class C, class D> string to_string(const tuple<A, B, C, D> &p);
string to_string(const string &s) { return '"' + s + '"'; }
string to_string(const char *s) { return to_string((string) s); }
string to_string(char c) { return "'" + string(1, c) + "'"; }
string to_string(bool x) { return x ? "true" : "false"; }
template<class A, class T = typename A::value_type> string to_string(const A &v) {
	bool first = 1;
	string res = "{";
	for (const auto &x: v) {
		if (!first) res += ", ";
		first = 0;
		res += to_string(x);
	}
	res += "}";
	return res;
}
template<class A, class B> string to_string(const pair<A, B> &p) {
	return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template<class A, class B, class C> string to_string(const tuple<A, B, C> &p) {
	return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}
template<class A, class B, class C, class D> string to_string(const tuple<A, B, C, D> &p) {
	return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}

void debug_out() { cerr << endl; }
template<class H, class... T> void debug_out(const H& h, const T&... t) {
	cerr << " " << to_string(h);
	debug_out(t...);
}
#ifndef ONLINE_JUDGE
	#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
	#define debug(...) if (0) puts("No effect.")
#endif

using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;


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

	int l, r; cin >> l >> r;
	if (l == r) {
		printf("%d\n", l);
	} else if (l + 1 == r) {
		printf("%d\n", -1);
	} else {
		printf("%d\n", r - 1);
	}
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

2 4

output:

3

result:

ok 1 number(s): "3"

Test #2:

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

input:

1 1

output:

1

result:

ok 1 number(s): "1"

Test #3:

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

input:

1 2

output:

-1

result:

ok 1 number(s): "-1"

Test #4:

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

input:

100 100

output:

100

result:

ok 1 number(s): "100"

Test #5:

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

input:

99 100

output:

-1

result:

ok 1 number(s): "-1"

Test #6:

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

input:

3 3

output:

3

result:

ok 1 number(s): "3"

Test #7:

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

input:

2 3

output:

-1

result:

ok 1 number(s): "-1"

Test #8:

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

input:

1 3

output:

2

result:

ok 1 number(s): "2"

Test #9:

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

input:

2 5

output:

4

result:

ok 1 number(s): "4"

Test #10:

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

input:

3 7

output:

6

result:

ok 1 number(s): "6"

Test #11:

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

input:

3 8

output:

7

result:

ok 1 number(s): "7"

Test #12:

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

input:

4 10

output:

9

result:

ok 1 number(s): "9"

Test #13:

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

input:

35 37

output:

36

result:

ok 1 number(s): "36"

Test #14:

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

input:

43 46

output:

45

result:

ok 1 number(s): "45"

Test #15:

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

input:

82 86

output:

85

result:

ok 1 number(s): "85"

Test #16:

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

input:

55 60

output:

59

result:

ok 1 number(s): "59"

Test #17:

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

input:

25 31

output:

30

result:

ok 1 number(s): "30"

Test #18:

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

input:

37 44

output:

43

result:

ok 1 number(s): "43"

Test #19:

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

input:

75 83

output:

82

result:

ok 1 number(s): "82"

Test #20:

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

input:

74 83

output:

82

result:

ok 1 number(s): "82"

Test #21:

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

input:

88 98

output:

97

result:

ok 1 number(s): "97"

Test #22:

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

input:

75 86

output:

85

result:

ok 1 number(s): "85"

Test #23:

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

input:

1 100

output:

99

result:

ok 1 number(s): "99"

Test #24:

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

input:

1 50

output:

49

result:

ok 1 number(s): "49"

Test #25:

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

input:

50 100

output:

99

result:

ok 1 number(s): "99"

Test #26:

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

input:

7 35

output:

34

result:

ok 1 number(s): "34"

Test #27:

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

input:

87 95

output:

94

result:

ok 1 number(s): "94"

Test #28:

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

input:

11 30

output:

29

result:

ok 1 number(s): "29"

Test #29:

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

input:

47 69

output:

68

result:

ok 1 number(s): "68"

Test #30:

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

input:

11 48

output:

47

result:

ok 1 number(s): "47"

Test #31:

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

input:

71 85

output:

84

result:

ok 1 number(s): "84"

Test #32:

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

input:

84 89

output:

88

result:

ok 1 number(s): "88"

Test #33:

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

input:

22 56

output:

55

result:

ok 1 number(s): "55"

Test #34:

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

input:

2 72

output:

71

result:

ok 1 number(s): "71"

Test #35:

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

input:

18 55

output:

54

result:

ok 1 number(s): "54"

Test #36:

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

input:

4 11

output:

10

result:

ok 1 number(s): "10"

Test #37:

score: 0
Accepted
time: 1ms
memory: 3788kb

input:

42 59

output:

58

result:

ok 1 number(s): "58"

Test #38:

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

input:

52 79

output:

78

result:

ok 1 number(s): "78"

Test #39:

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

input:

11 48

output:

47

result:

ok 1 number(s): "47"

Test #40:

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

input:

4 51

output:

50

result:

ok 1 number(s): "50"

Test #41:

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

input:

3 60

output:

59

result:

ok 1 number(s): "59"

Test #42:

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

input:

21 88

output:

87

result:

ok 1 number(s): "87"

Test #43:

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

input:

17 94

output:

93

result:

ok 1 number(s): "93"

Test #44:

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

input:

11 98

output:

97

result:

ok 1 number(s): "97"

Test #45:

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

input:

2 99

output:

98

result:

ok 1 number(s): "98"

Extra Test:

score: 0
Extra Test Passed