답안 #986569

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
986569 2024-05-20T18:58:43 Z activedeltorre Interval Collection (CCO20_day2problem2) C++14
3 / 25
7000 ms 616 KB
#include <iostream>
#include <vector>

using namespace std;
struct ura
{
    int a,b;
};
vector<ura>vec;
int inter(int i,int j)
{
    return max(0,min(vec[i].b,vec[j].b)-max(vec[i].a,vec[j].a));
}
int reun(int i,int j)
{
    return max(vec[i].b,vec[j].b)-min(vec[i].a,vec[j].a);

}
int main()
{
    int n,i,j,k,l,r,z;
    cin>>n;
    char tip;
    for(i=1;i<=n;i++)
    {
        cin>>tip;
        if(tip=='A')
        {
            cin>>l>>r;
            vec.push_back({l,r});
        }
        else if(tip=='R')
        {
            cin>>l>>r;
            for(j=0;j<vec.size();j++)
            {
                if(vec[j].a==l && vec[j].b==r)
                {
                    vec.erase(vec.begin()+j);
                    break;
                }
            }
        }
        int minim=1e9,sol;
        for(j=0;j<vec.size();j++)
        {
            for(z=j;z<vec.size();z++)
            {
                if(inter(z,j)<minim)
                {
                    minim=inter(z,j);
                    sol=reun(z,j);
                }
                else if(inter(z,j)==minim)
                {
                    sol=min(sol,reun(z,j));
                }
            }
        }
        cout<<sol<<'\n';
    }
    return 0;
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:35:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<ura>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   35 |             for(j=0;j<vec.size();j++)
      |                     ~^~~~~~~~~~~
Main.cpp:45:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<ura>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   45 |         for(j=0;j<vec.size();j++)
      |                 ~^~~~~~~~~~~
Main.cpp:47:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<ura>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   47 |             for(z=j;z<vec.size();z++)
      |                     ~^~~~~~~~~~~
Main.cpp:21:15: warning: unused variable 'k' [-Wunused-variable]
   21 |     int n,i,j,k,l,r,z;
      |               ^
Main.cpp:60:20: warning: 'sol' may be used uninitialized in this function [-Wmaybe-uninitialized]
   60 |         cout<<sol<<'\n';
      |                    ^~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 37 ms 604 KB Output is correct
2 Correct 4 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 2 ms 348 KB Output is correct
5 Correct 36 ms 448 KB Output is correct
6 Correct 3 ms 436 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 3 ms 440 KB Output is correct
9 Correct 50 ms 348 KB Output is correct
10 Correct 27 ms 348 KB Output is correct
11 Correct 23 ms 452 KB Output is correct
12 Correct 28 ms 448 KB Output is correct
13 Correct 72 ms 348 KB Output is correct
14 Correct 71 ms 444 KB Output is correct
15 Correct 75 ms 352 KB Output is correct
16 Correct 66 ms 448 KB Output is correct
17 Correct 44 ms 356 KB Output is correct
18 Correct 3 ms 356 KB Output is correct
19 Correct 1 ms 356 KB Output is correct
20 Correct 1 ms 356 KB Output is correct
21 Correct 34 ms 344 KB Output is correct
22 Correct 4 ms 356 KB Output is correct
23 Correct 2 ms 352 KB Output is correct
24 Correct 1 ms 352 KB Output is correct
25 Correct 51 ms 616 KB Output is correct
26 Correct 32 ms 356 KB Output is correct
27 Correct 26 ms 448 KB Output is correct
28 Correct 31 ms 612 KB Output is correct
29 Correct 75 ms 360 KB Output is correct
30 Correct 67 ms 356 KB Output is correct
31 Correct 73 ms 464 KB Output is correct
32 Correct 76 ms 356 KB Output is correct
33 Correct 1 ms 348 KB Output is correct
34 Correct 1 ms 604 KB Output is correct
35 Correct 1 ms 348 KB Output is correct
36 Correct 1 ms 604 KB Output is correct
37 Correct 2 ms 348 KB Output is correct
38 Correct 1 ms 348 KB Output is correct
39 Correct 2 ms 348 KB Output is correct
40 Correct 1 ms 348 KB Output is correct
41 Correct 19 ms 440 KB Output is correct
42 Correct 2 ms 348 KB Output is correct
43 Correct 2 ms 348 KB Output is correct
44 Correct 1 ms 348 KB Output is correct
45 Correct 16 ms 348 KB Output is correct
46 Correct 2 ms 348 KB Output is correct
47 Correct 1 ms 348 KB Output is correct
48 Correct 1 ms 348 KB Output is correct
49 Correct 25 ms 348 KB Output is correct
50 Correct 28 ms 604 KB Output is correct
51 Correct 28 ms 348 KB Output is correct
52 Correct 32 ms 352 KB Output is correct
53 Correct 24 ms 348 KB Output is correct
54 Correct 32 ms 348 KB Output is correct
55 Correct 24 ms 344 KB Output is correct
56 Correct 37 ms 348 KB Output is correct
57 Correct 33 ms 348 KB Output is correct
58 Correct 29 ms 344 KB Output is correct
59 Correct 63 ms 344 KB Output is correct
60 Correct 65 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 37 ms 604 KB Output is correct
2 Correct 4 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 2 ms 348 KB Output is correct
5 Correct 36 ms 448 KB Output is correct
6 Correct 3 ms 436 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 3 ms 440 KB Output is correct
9 Correct 50 ms 348 KB Output is correct
10 Correct 27 ms 348 KB Output is correct
11 Correct 23 ms 452 KB Output is correct
12 Correct 28 ms 448 KB Output is correct
13 Correct 72 ms 348 KB Output is correct
14 Correct 71 ms 444 KB Output is correct
15 Correct 75 ms 352 KB Output is correct
16 Correct 66 ms 448 KB Output is correct
17 Correct 44 ms 356 KB Output is correct
18 Correct 3 ms 356 KB Output is correct
19 Correct 1 ms 356 KB Output is correct
20 Correct 1 ms 356 KB Output is correct
21 Correct 34 ms 344 KB Output is correct
22 Correct 4 ms 356 KB Output is correct
23 Correct 2 ms 352 KB Output is correct
24 Correct 1 ms 352 KB Output is correct
25 Correct 51 ms 616 KB Output is correct
26 Correct 32 ms 356 KB Output is correct
27 Correct 26 ms 448 KB Output is correct
28 Correct 31 ms 612 KB Output is correct
29 Correct 75 ms 360 KB Output is correct
30 Correct 67 ms 356 KB Output is correct
31 Correct 73 ms 464 KB Output is correct
32 Correct 76 ms 356 KB Output is correct
33 Correct 1 ms 348 KB Output is correct
34 Correct 1 ms 604 KB Output is correct
35 Correct 1 ms 348 KB Output is correct
36 Correct 1 ms 604 KB Output is correct
37 Correct 2 ms 348 KB Output is correct
38 Correct 1 ms 348 KB Output is correct
39 Correct 2 ms 348 KB Output is correct
40 Correct 1 ms 348 KB Output is correct
41 Correct 19 ms 440 KB Output is correct
42 Correct 2 ms 348 KB Output is correct
43 Correct 2 ms 348 KB Output is correct
44 Correct 1 ms 348 KB Output is correct
45 Correct 16 ms 348 KB Output is correct
46 Correct 2 ms 348 KB Output is correct
47 Correct 1 ms 348 KB Output is correct
48 Correct 1 ms 348 KB Output is correct
49 Correct 25 ms 348 KB Output is correct
50 Correct 28 ms 604 KB Output is correct
51 Correct 28 ms 348 KB Output is correct
52 Correct 32 ms 352 KB Output is correct
53 Correct 24 ms 348 KB Output is correct
54 Correct 32 ms 348 KB Output is correct
55 Correct 24 ms 344 KB Output is correct
56 Correct 37 ms 348 KB Output is correct
57 Correct 33 ms 348 KB Output is correct
58 Correct 29 ms 344 KB Output is correct
59 Correct 63 ms 344 KB Output is correct
60 Correct 65 ms 348 KB Output is correct
61 Correct 0 ms 348 KB Output is correct
62 Correct 0 ms 348 KB Output is correct
63 Correct 0 ms 348 KB Output is correct
64 Execution timed out 7052 ms 588 KB Time limit exceeded
65 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 37 ms 604 KB Output is correct
2 Correct 4 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 2 ms 348 KB Output is correct
5 Correct 36 ms 448 KB Output is correct
6 Correct 3 ms 436 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 3 ms 440 KB Output is correct
9 Correct 50 ms 348 KB Output is correct
10 Correct 27 ms 348 KB Output is correct
11 Correct 23 ms 452 KB Output is correct
12 Correct 28 ms 448 KB Output is correct
13 Correct 72 ms 348 KB Output is correct
14 Correct 71 ms 444 KB Output is correct
15 Correct 75 ms 352 KB Output is correct
16 Correct 66 ms 448 KB Output is correct
17 Correct 44 ms 356 KB Output is correct
18 Correct 3 ms 356 KB Output is correct
19 Correct 1 ms 356 KB Output is correct
20 Correct 1 ms 356 KB Output is correct
21 Correct 34 ms 344 KB Output is correct
22 Correct 4 ms 356 KB Output is correct
23 Correct 2 ms 352 KB Output is correct
24 Correct 1 ms 352 KB Output is correct
25 Correct 51 ms 616 KB Output is correct
26 Correct 32 ms 356 KB Output is correct
27 Correct 26 ms 448 KB Output is correct
28 Correct 31 ms 612 KB Output is correct
29 Correct 75 ms 360 KB Output is correct
30 Correct 67 ms 356 KB Output is correct
31 Correct 73 ms 464 KB Output is correct
32 Correct 76 ms 356 KB Output is correct
33 Correct 1 ms 348 KB Output is correct
34 Correct 1 ms 604 KB Output is correct
35 Correct 1 ms 348 KB Output is correct
36 Correct 1 ms 604 KB Output is correct
37 Correct 2 ms 348 KB Output is correct
38 Correct 1 ms 348 KB Output is correct
39 Correct 2 ms 348 KB Output is correct
40 Correct 1 ms 348 KB Output is correct
41 Correct 19 ms 440 KB Output is correct
42 Correct 2 ms 348 KB Output is correct
43 Correct 2 ms 348 KB Output is correct
44 Correct 1 ms 348 KB Output is correct
45 Correct 16 ms 348 KB Output is correct
46 Correct 2 ms 348 KB Output is correct
47 Correct 1 ms 348 KB Output is correct
48 Correct 1 ms 348 KB Output is correct
49 Correct 25 ms 348 KB Output is correct
50 Correct 28 ms 604 KB Output is correct
51 Correct 28 ms 348 KB Output is correct
52 Correct 32 ms 352 KB Output is correct
53 Correct 24 ms 348 KB Output is correct
54 Correct 32 ms 348 KB Output is correct
55 Correct 24 ms 344 KB Output is correct
56 Correct 37 ms 348 KB Output is correct
57 Correct 33 ms 348 KB Output is correct
58 Correct 29 ms 344 KB Output is correct
59 Correct 63 ms 344 KB Output is correct
60 Correct 65 ms 348 KB Output is correct
61 Correct 0 ms 348 KB Output is correct
62 Correct 0 ms 348 KB Output is correct
63 Correct 0 ms 348 KB Output is correct
64 Execution timed out 7052 ms 588 KB Time limit exceeded
65 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 7069 ms 588 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 37 ms 604 KB Output is correct
2 Correct 4 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 2 ms 348 KB Output is correct
5 Correct 36 ms 448 KB Output is correct
6 Correct 3 ms 436 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 3 ms 440 KB Output is correct
9 Correct 50 ms 348 KB Output is correct
10 Correct 27 ms 348 KB Output is correct
11 Correct 23 ms 452 KB Output is correct
12 Correct 28 ms 448 KB Output is correct
13 Correct 72 ms 348 KB Output is correct
14 Correct 71 ms 444 KB Output is correct
15 Correct 75 ms 352 KB Output is correct
16 Correct 66 ms 448 KB Output is correct
17 Correct 44 ms 356 KB Output is correct
18 Correct 3 ms 356 KB Output is correct
19 Correct 1 ms 356 KB Output is correct
20 Correct 1 ms 356 KB Output is correct
21 Correct 34 ms 344 KB Output is correct
22 Correct 4 ms 356 KB Output is correct
23 Correct 2 ms 352 KB Output is correct
24 Correct 1 ms 352 KB Output is correct
25 Correct 51 ms 616 KB Output is correct
26 Correct 32 ms 356 KB Output is correct
27 Correct 26 ms 448 KB Output is correct
28 Correct 31 ms 612 KB Output is correct
29 Correct 75 ms 360 KB Output is correct
30 Correct 67 ms 356 KB Output is correct
31 Correct 73 ms 464 KB Output is correct
32 Correct 76 ms 356 KB Output is correct
33 Correct 1 ms 348 KB Output is correct
34 Correct 1 ms 604 KB Output is correct
35 Correct 1 ms 348 KB Output is correct
36 Correct 1 ms 604 KB Output is correct
37 Correct 2 ms 348 KB Output is correct
38 Correct 1 ms 348 KB Output is correct
39 Correct 2 ms 348 KB Output is correct
40 Correct 1 ms 348 KB Output is correct
41 Correct 19 ms 440 KB Output is correct
42 Correct 2 ms 348 KB Output is correct
43 Correct 2 ms 348 KB Output is correct
44 Correct 1 ms 348 KB Output is correct
45 Correct 16 ms 348 KB Output is correct
46 Correct 2 ms 348 KB Output is correct
47 Correct 1 ms 348 KB Output is correct
48 Correct 1 ms 348 KB Output is correct
49 Correct 25 ms 348 KB Output is correct
50 Correct 28 ms 604 KB Output is correct
51 Correct 28 ms 348 KB Output is correct
52 Correct 32 ms 352 KB Output is correct
53 Correct 24 ms 348 KB Output is correct
54 Correct 32 ms 348 KB Output is correct
55 Correct 24 ms 344 KB Output is correct
56 Correct 37 ms 348 KB Output is correct
57 Correct 33 ms 348 KB Output is correct
58 Correct 29 ms 344 KB Output is correct
59 Correct 63 ms 344 KB Output is correct
60 Correct 65 ms 348 KB Output is correct
61 Correct 0 ms 348 KB Output is correct
62 Correct 0 ms 348 KB Output is correct
63 Correct 0 ms 348 KB Output is correct
64 Execution timed out 7052 ms 588 KB Time limit exceeded
65 Halted 0 ms 0 KB -