Submission #925754

# Submission time Handle Problem Language Result Execution time Memory
925754 2024-02-12T08:18:28 Z andrei_boaca Team Contest (JOI22_team) C++17
55 / 100
2000 ms 5328 KB
#include <bits/stdc++.h>

using namespace std;
typedef pair<int,int> pii;
const int INF=1e9;
int lim=500;
int n;
struct point
{
    int x,y,z;
} v[150005];
bool byx(point a,point b)
{
    return a.x<b.x;
}
bool byy(pii a,pii b)
{
    if(a.first!=b.first)
        return a.first>b.first;
    return a.second<b.second;
}
bool byz(pii a,pii b)
{
    if(a.second!=b.second)
        return a.second>b.second;
    return a.first<b.first;
}
vector<pii> myy,myz;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    myy.push_back({-INF,INF});
    myz.push_back({INF,-INF});
    int maxim=0;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>v[i].x>>v[i].y>>v[i].z;
        maxim=max(maxim,v[i].x);
        maxim=max(maxim,v[i].y);
        maxim=max(maxim,v[i].z);
    }
    if(maxim<=300)
        lim=300;
    if(maxim<=20)
        lim=50;
    int ans=-1;
    sort(v+1,v+n+1,byx);
    for(int i=1;i<=n;i++)
    {
        vector<point> a;
        int j=i;
        while(j<=n&&v[j].x==v[i].x)
        {
            a.push_back(v[j]);
            j++;
        }
        for(point p:a)
        {
            for(pii ymax:myy)
            {
                if(ymax.first<=p.y)
                    continue;
                int z=-1;
                for(pii a:myz)
                    if(a.first<ymax.first&&a.second>ymax.second)
                    {
                        z=max(z,a.second);
                        break;
                    }
                if(z!=-1)
                {
                    if(z>p.z)
                        ans=max(ans,ymax.first+z+p.x);
                    break;
                }
            }
        }
        for(point p:a)
        {
            myy.push_back({p.y,p.z});
            sort(myy.begin(),myy.end(),byy);
            myy.erase(unique(myy.begin(),myy.end()),myy.end());
            if(myy.size()>lim)
                myy.pop_back();
            myz.push_back({p.y,p.z});
            sort(myz.begin(),myz.end(),byz);
            myz.erase(unique(myz.begin(),myz.end()),myz.end());
            if(myz.size()>lim)
                myz.pop_back();
        }
        i=j-1;
    }
    cout<<ans;
    return 0;
}

Compilation message

team.cpp: In function 'int main()':
team.cpp:85:26: warning: comparison of integer expressions of different signedness: 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   85 |             if(myy.size()>lim)
      |                ~~~~~~~~~~^~~~
team.cpp:90:26: warning: comparison of integer expressions of different signedness: 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   90 |             if(myz.size()>lim)
      |                ~~~~~~~~~~^~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 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 1 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 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 344 KB Output is correct
14 Correct 4 ms 344 KB Output is correct
15 Correct 3 ms 348 KB Output is correct
16 Correct 4 ms 348 KB Output is correct
17 Correct 5 ms 348 KB Output is correct
18 Correct 4 ms 348 KB Output is correct
19 Correct 5 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 1 ms 484 KB Output is correct
22 Correct 6 ms 400 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 4 ms 424 KB Output is correct
25 Correct 4 ms 472 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 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 1 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 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 344 KB Output is correct
14 Correct 4 ms 344 KB Output is correct
15 Correct 3 ms 348 KB Output is correct
16 Correct 4 ms 348 KB Output is correct
17 Correct 5 ms 348 KB Output is correct
18 Correct 4 ms 348 KB Output is correct
19 Correct 5 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 1 ms 484 KB Output is correct
22 Correct 6 ms 400 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 4 ms 424 KB Output is correct
25 Correct 4 ms 472 KB Output is correct
26 Correct 129 ms 504 KB Output is correct
27 Correct 261 ms 348 KB Output is correct
28 Correct 361 ms 512 KB Output is correct
29 Correct 439 ms 508 KB Output is correct
30 Correct 260 ms 496 KB Output is correct
31 Correct 228 ms 344 KB Output is correct
32 Correct 160 ms 516 KB Output is correct
33 Correct 98 ms 572 KB Output is correct
34 Correct 284 ms 524 KB Output is correct
35 Correct 28 ms 484 KB Output is correct
36 Correct 29 ms 348 KB Output is correct
37 Correct 290 ms 508 KB Output is correct
38 Correct 284 ms 344 KB Output is correct
39 Correct 4 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 600 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 1 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 151 ms 2936 KB Output is correct
12 Correct 86 ms 2380 KB Output is correct
13 Correct 50 ms 3332 KB Output is correct
14 Correct 90 ms 3404 KB Output is correct
15 Correct 49 ms 4380 KB Output is correct
16 Correct 35 ms 5328 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 600 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 1 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 151 ms 2936 KB Output is correct
12 Correct 86 ms 2380 KB Output is correct
13 Correct 50 ms 3332 KB Output is correct
14 Correct 90 ms 3404 KB Output is correct
15 Correct 49 ms 4380 KB Output is correct
16 Correct 35 ms 5328 KB Output is correct
17 Correct 0 ms 344 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 344 KB Output is correct
20 Correct 1 ms 344 KB Output is correct
21 Correct 5 ms 348 KB Output is correct
22 Correct 304 ms 2428 KB Output is correct
23 Correct 423 ms 2624 KB Output is correct
24 Correct 317 ms 1880 KB Output is correct
25 Correct 379 ms 2680 KB Output is correct
26 Correct 84 ms 3668 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 600 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 1 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 151 ms 2936 KB Output is correct
12 Correct 86 ms 2380 KB Output is correct
13 Correct 50 ms 3332 KB Output is correct
14 Correct 90 ms 3404 KB Output is correct
15 Correct 49 ms 4380 KB Output is correct
16 Correct 35 ms 5328 KB Output is correct
17 Correct 0 ms 344 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 344 KB Output is correct
20 Correct 1 ms 344 KB Output is correct
21 Correct 5 ms 348 KB Output is correct
22 Correct 304 ms 2428 KB Output is correct
23 Correct 423 ms 2624 KB Output is correct
24 Correct 317 ms 1880 KB Output is correct
25 Correct 379 ms 2680 KB Output is correct
26 Correct 84 ms 3668 KB Output is correct
27 Correct 4 ms 344 KB Output is correct
28 Correct 5 ms 344 KB Output is correct
29 Correct 4 ms 348 KB Output is correct
30 Correct 4 ms 348 KB Output is correct
31 Correct 166 ms 512 KB Output is correct
32 Correct 28 ms 348 KB Output is correct
33 Correct 28 ms 348 KB Output is correct
34 Execution timed out 2048 ms 2060 KB Time limit exceeded
35 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 600 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 1 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 151 ms 2936 KB Output is correct
12 Correct 86 ms 2380 KB Output is correct
13 Correct 50 ms 3332 KB Output is correct
14 Correct 90 ms 3404 KB Output is correct
15 Correct 49 ms 4380 KB Output is correct
16 Correct 35 ms 5328 KB Output is correct
17 Correct 0 ms 344 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 344 KB Output is correct
20 Correct 1 ms 344 KB Output is correct
21 Correct 5 ms 348 KB Output is correct
22 Correct 304 ms 2428 KB Output is correct
23 Correct 423 ms 2624 KB Output is correct
24 Correct 317 ms 1880 KB Output is correct
25 Correct 379 ms 2680 KB Output is correct
26 Correct 84 ms 3668 KB Output is correct
27 Correct 4 ms 344 KB Output is correct
28 Correct 5 ms 344 KB Output is correct
29 Correct 4 ms 348 KB Output is correct
30 Correct 4 ms 348 KB Output is correct
31 Correct 166 ms 512 KB Output is correct
32 Correct 28 ms 348 KB Output is correct
33 Correct 28 ms 348 KB Output is correct
34 Execution timed out 2048 ms 2060 KB Time limit exceeded
35 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 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 1 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 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 344 KB Output is correct
14 Correct 4 ms 344 KB Output is correct
15 Correct 3 ms 348 KB Output is correct
16 Correct 4 ms 348 KB Output is correct
17 Correct 5 ms 348 KB Output is correct
18 Correct 4 ms 348 KB Output is correct
19 Correct 5 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 1 ms 484 KB Output is correct
22 Correct 6 ms 400 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 4 ms 424 KB Output is correct
25 Correct 4 ms 472 KB Output is correct
26 Correct 129 ms 504 KB Output is correct
27 Correct 261 ms 348 KB Output is correct
28 Correct 361 ms 512 KB Output is correct
29 Correct 439 ms 508 KB Output is correct
30 Correct 260 ms 496 KB Output is correct
31 Correct 228 ms 344 KB Output is correct
32 Correct 160 ms 516 KB Output is correct
33 Correct 98 ms 572 KB Output is correct
34 Correct 284 ms 524 KB Output is correct
35 Correct 28 ms 484 KB Output is correct
36 Correct 29 ms 348 KB Output is correct
37 Correct 290 ms 508 KB Output is correct
38 Correct 284 ms 344 KB Output is correct
39 Correct 4 ms 348 KB Output is correct
40 Correct 0 ms 344 KB Output is correct
41 Correct 0 ms 348 KB Output is correct
42 Correct 1 ms 600 KB Output is correct
43 Correct 0 ms 348 KB Output is correct
44 Correct 0 ms 348 KB Output is correct
45 Correct 0 ms 348 KB Output is correct
46 Correct 0 ms 348 KB Output is correct
47 Correct 1 ms 348 KB Output is correct
48 Correct 0 ms 348 KB Output is correct
49 Correct 0 ms 348 KB Output is correct
50 Correct 151 ms 2936 KB Output is correct
51 Correct 86 ms 2380 KB Output is correct
52 Correct 50 ms 3332 KB Output is correct
53 Correct 90 ms 3404 KB Output is correct
54 Correct 49 ms 4380 KB Output is correct
55 Correct 35 ms 5328 KB Output is correct
56 Correct 0 ms 344 KB Output is correct
57 Correct 0 ms 348 KB Output is correct
58 Correct 0 ms 344 KB Output is correct
59 Correct 1 ms 344 KB Output is correct
60 Correct 5 ms 348 KB Output is correct
61 Correct 304 ms 2428 KB Output is correct
62 Correct 423 ms 2624 KB Output is correct
63 Correct 317 ms 1880 KB Output is correct
64 Correct 379 ms 2680 KB Output is correct
65 Correct 84 ms 3668 KB Output is correct
66 Correct 4 ms 344 KB Output is correct
67 Correct 5 ms 344 KB Output is correct
68 Correct 4 ms 348 KB Output is correct
69 Correct 4 ms 348 KB Output is correct
70 Correct 166 ms 512 KB Output is correct
71 Correct 28 ms 348 KB Output is correct
72 Correct 28 ms 348 KB Output is correct
73 Execution timed out 2048 ms 2060 KB Time limit exceeded
74 Halted 0 ms 0 KB -