답안 #719751

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
719751 2023-04-06T15:33:59 Z lam Team Contest (JOI22_team) C++14
36 / 100
121 ms 6044 KB
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int maxn = 1e5 + 5e4 + 10;
typedef pair<int,int> ii;
typedef pair<int,ii> iii;
#define ff first
#define ss second
int n;
iii a[maxn];
vector <iii> d;
map<ii,bool> mp;
int mmin[maxn],mmax[maxn];
ii vval;
void add(iii x)
{
//    cout<<"+ "<<x.ff<<' '<<x.ss.ff<<' '<<x.ss.ss<<'\n';
    int y = x.ss.ff;
    mmax[y]=max(mmax[y],x.ss.ss);
    mmin[y]=min(mmin[y],x.ss.ss);
}
int query(iii x)
{
    int y=x.ss.ff;
    int ans=-1;
    if (vval.ff!=-1&&vval.ss>x.ss.ss&&vval.ff>y) ans=max(ans,vval.ff+vval.ss+x.ff);
    return ans;
}
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);
    cin>>n;
    for (int i=1; i<=n; i++) cin>>a[i].ff>>a[i].ss.ff>>a[i].ss.ss;
    for (int i=0; i<=4000; i++)
        mmin[i] = 1e9, mmax[i]=-1e9;
    sort(a+1,a+n+1);
    d.clear();
    int l,r;
    int ans=-1;
    for (int i=1; i<=n; i++)
    {
        if (i==1||a[i].ff!=a[i-1].ff) l=i;
        if (i==n||a[i].ff!=a[i+1].ff)
        {
            r=i;
            int l2,r2;
            vval={-1,-1};
            for (int j=4000; j>=1; j--) if (mmin[j]!=1e9&&mmax[j-1]!=-1e9&&mmax[j-1]>mmin[j])
            {
                vval = {j,mmax[j-1]};
                break;
            }
//            cout<<a[i].ff<<" := "<<vval.ff<<' '<<vval.ss<<'\n';
//            for (int j=1; j<=10; j++) cout<<mmin[j]<<','<<mmax[j]<<"  "; cout<<'\n';
            for (int j=l; j<=r; j++)
            {
                if (j==l||a[j].ss.ff!=a[j-1].ss.ff) l2=j;
                if (j==r||a[j].ss.ff!=a[j+1].ss.ff)
                {
                    r2=j;
                    ans=max(ans,query(a[l2]));
                    ans=max(ans,query(a[r2]));
                }
            }
            for (int j=l; j<=r; j++)
            {
                if (j==l||a[j].ss.ff!=a[j-1].ss.ff) l2=j;
                if (j==r||a[j].ss.ff!=a[j+1].ss.ff)
                {
                    r2=j;
                    add(a[r2]);
                    add(a[l2]);
                }
            }
            for (int j=1; j<=4000; j++) mmax[j]=max(mmax[j],mmax[j-1]);
        }
    }
    cout<<ans<<'\n';
}

Compilation message

team.cpp: In function 'int main()':
team.cpp:47:17: warning: 'l2' may be used uninitialized in this function [-Wmaybe-uninitialized]
   47 |             int l2,r2;
      |                 ^~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 332 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 296 KB Output is correct
14 Runtime error 2 ms 596 KB Execution killed with signal 11
15 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 332 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 296 KB Output is correct
14 Runtime error 2 ms 596 KB Execution killed with signal 11
15 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 34 ms 4252 KB Output is correct
12 Correct 23 ms 3136 KB Output is correct
13 Correct 32 ms 3628 KB Output is correct
14 Correct 33 ms 4184 KB Output is correct
15 Correct 29 ms 4252 KB Output is correct
16 Correct 27 ms 4172 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 34 ms 4252 KB Output is correct
12 Correct 23 ms 3136 KB Output is correct
13 Correct 32 ms 3628 KB Output is correct
14 Correct 33 ms 4184 KB Output is correct
15 Correct 29 ms 4252 KB Output is correct
16 Correct 27 ms 4172 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 2 ms 476 KB Output is correct
22 Correct 43 ms 4172 KB Output is correct
23 Correct 51 ms 4172 KB Output is correct
24 Correct 34 ms 3312 KB Output is correct
25 Correct 41 ms 4276 KB Output is correct
26 Correct 31 ms 4312 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 34 ms 4252 KB Output is correct
12 Correct 23 ms 3136 KB Output is correct
13 Correct 32 ms 3628 KB Output is correct
14 Correct 33 ms 4184 KB Output is correct
15 Correct 29 ms 4252 KB Output is correct
16 Correct 27 ms 4172 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 2 ms 476 KB Output is correct
22 Correct 43 ms 4172 KB Output is correct
23 Correct 51 ms 4172 KB Output is correct
24 Correct 34 ms 3312 KB Output is correct
25 Correct 41 ms 4276 KB Output is correct
26 Correct 31 ms 4312 KB Output is correct
27 Correct 3 ms 340 KB Output is correct
28 Correct 2 ms 340 KB Output is correct
29 Correct 3 ms 340 KB Output is correct
30 Correct 3 ms 340 KB Output is correct
31 Correct 8 ms 476 KB Output is correct
32 Correct 6 ms 340 KB Output is correct
33 Correct 7 ms 340 KB Output is correct
34 Correct 51 ms 4096 KB Output is correct
35 Correct 50 ms 4004 KB Output is correct
36 Correct 56 ms 4504 KB Output is correct
37 Correct 53 ms 4392 KB Output is correct
38 Correct 45 ms 4412 KB Output is correct
39 Correct 23 ms 2976 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 34 ms 4252 KB Output is correct
12 Correct 23 ms 3136 KB Output is correct
13 Correct 32 ms 3628 KB Output is correct
14 Correct 33 ms 4184 KB Output is correct
15 Correct 29 ms 4252 KB Output is correct
16 Correct 27 ms 4172 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 2 ms 476 KB Output is correct
22 Correct 43 ms 4172 KB Output is correct
23 Correct 51 ms 4172 KB Output is correct
24 Correct 34 ms 3312 KB Output is correct
25 Correct 41 ms 4276 KB Output is correct
26 Correct 31 ms 4312 KB Output is correct
27 Correct 3 ms 340 KB Output is correct
28 Correct 2 ms 340 KB Output is correct
29 Correct 3 ms 340 KB Output is correct
30 Correct 3 ms 340 KB Output is correct
31 Correct 8 ms 476 KB Output is correct
32 Correct 6 ms 340 KB Output is correct
33 Correct 7 ms 340 KB Output is correct
34 Correct 51 ms 4096 KB Output is correct
35 Correct 50 ms 4004 KB Output is correct
36 Correct 56 ms 4504 KB Output is correct
37 Correct 53 ms 4392 KB Output is correct
38 Correct 45 ms 4412 KB Output is correct
39 Correct 23 ms 2976 KB Output is correct
40 Correct 30 ms 488 KB Output is correct
41 Correct 21 ms 468 KB Output is correct
42 Correct 29 ms 532 KB Output is correct
43 Correct 27 ms 472 KB Output is correct
44 Correct 110 ms 5980 KB Output is correct
45 Correct 107 ms 5964 KB Output is correct
46 Correct 121 ms 5968 KB Output is correct
47 Correct 118 ms 6044 KB Output is correct
48 Correct 58 ms 5836 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 332 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 296 KB Output is correct
14 Runtime error 2 ms 596 KB Execution killed with signal 11
15 Halted 0 ms 0 KB -