답안 #719685

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
719685 2023-04-06T13:39:42 Z lam Team Contest (JOI22_team) C++14
55 / 100
2000 ms 7536 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;

bool cmpx(iii x, iii y)
{
    return x.ff<y.ff;
}
bool cmpy(iii x, iii y)
{
    return x.ss.ff<y.ss.ff;
}
void add(iii x)
{
    if (mp[x.ss]) return;
    mp[x.ss]=1;
    d.push_back(x);
    for (int i=d.size()-1; i>=1; i--)
        if (cmpy(d[i],d[i-1])) swap(d[i],d[i-1]);
        else break;
}
int query(iii x)
{
    int l,r;
    int mmax = -1;
    int ans=-1;
    for (int i=0; i<d.size(); i++)
    {
        if (i==0||d[i].ss.ff!=d[i-1].ss.ff) l=i;
        if (i==d.size()-1||d[i].ss.ff!=d[i+1].ss.ff)
        {
            r=i;
            for (int j=l; j<=r; j++)
                if (d[j].ss.ff > x.ss.ff)
                    if (mmax>d[j].ss.ss&&mmax>x.ss.ss) ans=max(ans,mmax+d[j].ss.ff+x.ff);
            for (int j=l; j<=r; j++) mmax=max(mmax,d[j].ss.ss);
        }
    }
    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;
    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;
            for (int j=l; j<=r; j++) ans=max(ans,query(a[j]));
            for (int j=l; j<=r; j++) add(a[j]);
        }
    }
    cout<<ans<<'\n';
}

Compilation message

team.cpp: In function 'long long int query(iii)':
team.cpp:36:20: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, std::pair<long long int, long long int> > >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   36 |     for (int i=0; i<d.size(); i++)
      |                   ~^~~~~~~~~
team.cpp:39:14: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, std::pair<long long int, long long int> > >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   39 |         if (i==d.size()-1||d[i].ss.ff!=d[i+1].ss.ff)
      |             ~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 224 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 340 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 1 ms 340 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 224 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 340 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 1 ms 340 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 40 ms 700 KB Output is correct
27 Correct 59 ms 724 KB Output is correct
28 Correct 44 ms 720 KB Output is correct
29 Correct 40 ms 716 KB Output is correct
30 Correct 19 ms 628 KB Output is correct
31 Correct 50 ms 792 KB Output is correct
32 Correct 23 ms 560 KB Output is correct
33 Correct 2 ms 468 KB Output is correct
34 Correct 25 ms 680 KB Output is correct
35 Correct 2 ms 340 KB Output is correct
36 Correct 2 ms 340 KB Output is correct
37 Correct 31 ms 540 KB Output is correct
38 Correct 24 ms 652 KB Output is correct
39 Correct 4 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 43 ms 3732 KB Output is correct
12 Correct 25 ms 3220 KB Output is correct
13 Correct 26 ms 3924 KB Output is correct
14 Correct 42 ms 4688 KB Output is correct
15 Correct 33 ms 4696 KB Output is correct
16 Correct 29 ms 4696 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 43 ms 3732 KB Output is correct
12 Correct 25 ms 3220 KB Output is correct
13 Correct 26 ms 3924 KB Output is correct
14 Correct 42 ms 4688 KB Output is correct
15 Correct 33 ms 4696 KB Output is correct
16 Correct 29 ms 4696 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 4 ms 340 KB Output is correct
22 Correct 194 ms 4956 KB Output is correct
23 Correct 75 ms 4604 KB Output is correct
24 Correct 66 ms 3648 KB Output is correct
25 Correct 86 ms 4984 KB Output is correct
26 Correct 32 ms 4824 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 43 ms 3732 KB Output is correct
12 Correct 25 ms 3220 KB Output is correct
13 Correct 26 ms 3924 KB Output is correct
14 Correct 42 ms 4688 KB Output is correct
15 Correct 33 ms 4696 KB Output is correct
16 Correct 29 ms 4696 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 4 ms 340 KB Output is correct
22 Correct 194 ms 4956 KB Output is correct
23 Correct 75 ms 4604 KB Output is correct
24 Correct 66 ms 3648 KB Output is correct
25 Correct 86 ms 4984 KB Output is correct
26 Correct 32 ms 4824 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
28 Correct 1 ms 340 KB Output is correct
29 Correct 1 ms 340 KB Output is correct
30 Correct 1 ms 340 KB Output is correct
31 Correct 26 ms 688 KB Output is correct
32 Correct 2 ms 344 KB Output is correct
33 Correct 2 ms 340 KB Output is correct
34 Execution timed out 2055 ms 7536 KB Time limit exceeded
35 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 43 ms 3732 KB Output is correct
12 Correct 25 ms 3220 KB Output is correct
13 Correct 26 ms 3924 KB Output is correct
14 Correct 42 ms 4688 KB Output is correct
15 Correct 33 ms 4696 KB Output is correct
16 Correct 29 ms 4696 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 4 ms 340 KB Output is correct
22 Correct 194 ms 4956 KB Output is correct
23 Correct 75 ms 4604 KB Output is correct
24 Correct 66 ms 3648 KB Output is correct
25 Correct 86 ms 4984 KB Output is correct
26 Correct 32 ms 4824 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
28 Correct 1 ms 340 KB Output is correct
29 Correct 1 ms 340 KB Output is correct
30 Correct 1 ms 340 KB Output is correct
31 Correct 26 ms 688 KB Output is correct
32 Correct 2 ms 344 KB Output is correct
33 Correct 2 ms 340 KB Output is correct
34 Execution timed out 2055 ms 7536 KB Time limit exceeded
35 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 224 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 340 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 1 ms 340 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 40 ms 700 KB Output is correct
27 Correct 59 ms 724 KB Output is correct
28 Correct 44 ms 720 KB Output is correct
29 Correct 40 ms 716 KB Output is correct
30 Correct 19 ms 628 KB Output is correct
31 Correct 50 ms 792 KB Output is correct
32 Correct 23 ms 560 KB Output is correct
33 Correct 2 ms 468 KB Output is correct
34 Correct 25 ms 680 KB Output is correct
35 Correct 2 ms 340 KB Output is correct
36 Correct 2 ms 340 KB Output is correct
37 Correct 31 ms 540 KB Output is correct
38 Correct 24 ms 652 KB Output is correct
39 Correct 4 ms 340 KB Output is correct
40 Correct 0 ms 212 KB Output is correct
41 Correct 1 ms 212 KB Output is correct
42 Correct 1 ms 212 KB Output is correct
43 Correct 0 ms 212 KB Output is correct
44 Correct 1 ms 212 KB Output is correct
45 Correct 0 ms 212 KB Output is correct
46 Correct 1 ms 212 KB Output is correct
47 Correct 1 ms 212 KB Output is correct
48 Correct 1 ms 212 KB Output is correct
49 Correct 1 ms 212 KB Output is correct
50 Correct 43 ms 3732 KB Output is correct
51 Correct 25 ms 3220 KB Output is correct
52 Correct 26 ms 3924 KB Output is correct
53 Correct 42 ms 4688 KB Output is correct
54 Correct 33 ms 4696 KB Output is correct
55 Correct 29 ms 4696 KB Output is correct
56 Correct 1 ms 212 KB Output is correct
57 Correct 1 ms 212 KB Output is correct
58 Correct 1 ms 212 KB Output is correct
59 Correct 1 ms 340 KB Output is correct
60 Correct 4 ms 340 KB Output is correct
61 Correct 194 ms 4956 KB Output is correct
62 Correct 75 ms 4604 KB Output is correct
63 Correct 66 ms 3648 KB Output is correct
64 Correct 86 ms 4984 KB Output is correct
65 Correct 32 ms 4824 KB Output is correct
66 Correct 1 ms 340 KB Output is correct
67 Correct 1 ms 340 KB Output is correct
68 Correct 1 ms 340 KB Output is correct
69 Correct 1 ms 340 KB Output is correct
70 Correct 26 ms 688 KB Output is correct
71 Correct 2 ms 344 KB Output is correct
72 Correct 2 ms 340 KB Output is correct
73 Execution timed out 2055 ms 7536 KB Time limit exceeded
74 Halted 0 ms 0 KB -