UOJ Logo

NOI.AC

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#212180#3816. 元素Panjunnan0510ms1308kbC++11751b2024-10-13 11:52:482024-10-13 12:30:23

answer

#include <iostream>
#include <vector>
#include <set>
#include <algorithm>

using namespace std;

int main() {
    int n, q;
    cin >> n >> q;
    
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    

    for (int i = 0; i < q; i++) {
        int l, r;
        cin >> l >> r;
        l--; r--; 
        

        set<int> elements;
        for (int j = l; j <= r; j++) {
            elements.insert(a[j]);
        }
        

        auto minMax = minmax_element(elements.begin(), elements.end());
        int min_val = *minMax.first;   
        int max_val = *minMax.second;   
        int result = max_val - min_val + 1;
        cout << result << endl; 
    }

    return 0;
}

详细

小提示:点击横条可展开更详细的信息

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 1240kb

input:

10 10
492 1887 1028 1209 252 1860 1527 699 1656 928
6 9
2 8
3 10
2 3
1 8
6 9
3 5
4 7
1 4
2 7

output:

1162
1636
1609
860
1636
1162
958
1609
1396
1636

result:

wrong answer 1st numbers differ - expected: '4', found: '1162'

Test #2:

score: 0
Wrong Answer
time: 2ms
memory: 1240kb

input:

50 50
413 1208 1780 279 1403 1706 11 1583 333 355 1068 1270 1835 1042 957 423 1140 1153 1709 284 281...

output:

1527
1672
1840
1814
1730
1942
1748
1814
1968
1711
1814
1555
1575
1447
1158
1473
1814
922
1942
1730
1...

result:

wrong answer 1st numbers differ - expected: '10', found: '1527'

Test #3:

score: 0
Wrong Answer
time: 0ms
memory: 1240kb

input:

50 50
407 1089 1459 1626 1917 555 1611 492 443 1149 406 1259 1729 1554 577 1310 1899 1578 1005 1459 ...

output:

1884
1494
1325
1494
1
1923
1
1923
1776
1923
1923
1884
1512
1923
1324
1923
50
1111
1923
1
1776
1866
1...

result:

wrong answer 1st numbers differ - expected: '32', found: '1884'

Test #4:

score: 0
Wrong Answer
time: 2ms
memory: 1244kb

input:

50 50
1792 843 1272 547 698 1086 1174 1607 1277 1055 506 881 1445 372 1076 1770 647 1086 320 1912 18...

output:

1889
1889
1878
1889
1732
1732
1473
1889
1095
1889
408
1878
1889
1732
1878
1732
1732
1889
1399
1802
7...

result:

wrong answer 1st numbers differ - expected: '34', found: '1889'

Test #5:

score: 0
Wrong Answer
time: 0ms
memory: 1240kb

input:

50 50
44 1463 245 1177 1728 1335 768 475 790 623 1466 98 672 230 339 1428 872 1905 405 1260 1503 813...

output:

1676
1808
1
1505
1610
1704
1895
1895
1808
1
1808
1895
1567
1808
762
763
1808
1895
1369
1862
1895
159...

result:

wrong answer 1st numbers differ - expected: '19', found: '1676'

Test #6:

score: 0
Wrong Answer
time: 0ms
memory: 1240kb

input:

50 50
695 974 1078 231 500 498 1308 1666 1925 766 1994 1776 1955 1766 1191 1021 1581 1202 615 1230 1...

output:

1215
1475
1980
1984
1764
1229
1984
1460
1692
1984
1984
1460
1984
1511
1764
1511
1497
1511
1980
1208
...

result:

wrong answer 1st numbers differ - expected: '11', found: '1215'

Test #7:

score: 0
Wrong Answer
time: 3ms
memory: 1252kb

input:

200 200
403 329 389 1103 695 1865 818 671 750 1868 1422 422 1186 1431 172 1569 460 1580 406 1049 138...

output:

2000
1987
1749
1787
1949
1893
1991
1979
2000
1771
1987
1979
1922
1987
1987
1949
1991
1949
1576
1987
...

result:

wrong answer 1st numbers differ - expected: '131', found: '2000'

Test #8:

score: 0
Wrong Answer
time: 2ms
memory: 1248kb

input:

200 200
147 1386 1788 1493 1919 1136 861 871 1895 1006 1776 346 381 1666 296 289 568 1616 1535 531 2...

output:

1973
1901
1999
1999
1650
530
1925
1999
1955
1999
1869
1901
1775
1973
482
1973
1999
1862
1921
1862
17...

result:

wrong answer 1st numbers differ - expected: '103', found: '1973'

Test #9:

score: 0
Wrong Answer
time: 246ms
memory: 1308kb

input:

2000 2000
1154 852 1088 1530 639 1318 1250 1222 1341 1070 205 656 903 1491 808 317 756 1962 102 1445...

output:

2000
1998
1999
1933
1999
2000
2000
2000
2000
2000
2000
2000
2000
1975
1999
2000
2000
2000
1977
1998
...

result:

wrong answer 1st numbers differ - expected: '830', found: '2000'

Test #10:

score: 0
Wrong Answer
time: 255ms
memory: 1308kb

input:

2000 2000
1232 731 1651 991 1681 1739 776 240 829 1337 493 248 214 1852 716 325 1280 1207 380 724 11...

output:

1994
1994
1994
1994
1991
1982
1994
1994
1994
1983
1994
1992
1989
1988
1992
1994
1992
1851
1994
1966
...

result:

wrong answer 1st numbers differ - expected: '1062', found: '1994'