QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#124987#3506. Team ContestArgo0 51ms7328kbC++142.6kb2023-07-15 21:43:002023-07-15 21:43:00

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-07-15 21:43:00]
  • 评测
  • 测评结果:0
  • 用时:51ms
  • 内存:7328kb
  • [2023-07-15 21:43:00]
  • 提交

answer

#include<bits/stdc++.h>

using namespace std;
#define rozmiar 1000000

int n, d, e, f;
vector<pair<int, int>> a, b, c;
bool wyjebani[rozmiar];

int main(){
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    cin >> n;
    for(int i=0;i<n;i++){
        cin >> d >> e >> f;
        a.push_back({d, i});
        b.push_back({e, i});
        c.push_back({f, i});
    }
    a.push_back({0, 0});
    b.push_back({0, 0});
    c.push_back({0, 0});
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    sort(c.begin(), c.end());
    int it1=n, it2=n, it3=n;
    while(1){
        while(wyjebani[a[it1].second] && it1>0)it1--;
        while(wyjebani[b[it2].second] && it2>0)it2--;
        while(wyjebani[c[it3].second] && it3>0)it3--;
        if(it1==0 || it2==0 || it3==0){
            cout << -1 << endl;
            return 0;
        }
        if(a[it1].second==b[it2].second){
            wyjebani[a[it1].second]=1;
            it1--;
            it2--;
        }else{
            if(a[it1].second==c[it3].second){
            wyjebani[a[it1].second]=1;
            it1--;
            it3--;
        }else{
             if(c[it3].second==b[it2].second){
            wyjebani[c[it3].second]=1;
            it3--;
            it2--;
        }else{
            cout << a[it1].first+b[it2].first+c[it3].first << endl;
            return 0;
        }
        }
        }
    }
    //while(1){
    //    //  cout << it1 << " " << it2 << " " << it3 << endl;
    //    if((it1==0 && wyjebani[a[it1][3]]) || it1<0 || it2<0 || it3<0){cout << -1 << endl;return 0;}
    //    while(wyjebani[a[it1][3]] && it1>0)it1--;
    //    while(wyjebani[b[it2][3]] && it2>0)it2--;
    //    while(wyjebani[c[it3][3]] && it3>0)it3--;
    //    if((it1==0 && wyjebani[a[it1][3]]) || (it2==0 && wyjebani[a[it2][3]]) || (it3==0 && wyjebani[a[it3][3]]) || it1<0 || it2<0 || it3<0){cout << -1 << endl;return 0;} 
    //    if(a[it1][1]>=max(b[it2][0], c[it3][2]) || a[it1][2]>=max(b[it2][2], c[it3][0])){
    //        wyjebani[a[it1][3]]=1;
    //        it1--;
    //    }else{
    //        if(b[it2][1]>=max(a[it1][0], c[it3][2]) || b[it2][2]>=max(a[it1][2], c[it3][0])){
    //        wyjebani[b[it2][3]]=1;
    //            it2--;
    //        }else if(c[it2][1]>=max(a[it1][0], b[it2][1]) || c[it3][2]>=max(a[it1][1], b[it2][0])){
    //        wyjebani[c[it3][3]]=1;
    //            it3--;
    //        }else{
    //            cout << a[it1][0]+b[it2][0]+c[it3][0] << endl;
    //            return 0;
    //        }
    //    }
    //    
    //}
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 8
Accepted
time: 0ms
memory: 3512kb

input:

3
1 1 2
1 2 1
2 1 1

output:

6

result:

ok single line: '6'

Test #2:

score: 0
Accepted
time: 0ms
memory: 3408kb

input:

3
1 2 2
2 1 2
2 2 1

output:

-1

result:

ok single line: '-1'

Test #3:

score: 0
Accepted
time: 1ms
memory: 3404kb

input:

3
3 3 3
2 2 2
1 1 1

output:

-1

result:

ok single line: '-1'

Test #4:

score: 0
Accepted
time: 1ms
memory: 3404kb

input:

4
3 1 1
2 2 2
1 1 3
1 2 1

output:

8

result:

ok single line: '8'

Test #5:

score: 0
Accepted
time: 0ms
memory: 3404kb

input:

3
1 2 3
1 3 4
1 4 2

output:

-1

result:

ok single line: '-1'

Test #6:

score: 0
Accepted
time: 1ms
memory: 3496kb

input:

3
4 1 3
3 1 2
2 1 4

output:

-1

result:

ok single line: '-1'

Test #7:

score: -8
Wrong Answer
time: 0ms
memory: 3428kb

input:

3
2 4 1
4 3 1
3 2 1

output:

9

result:

wrong answer 1st lines differ - expected: '-1', found: '9'

Subtask #2:

score: 0
Skipped

Dependency #1:

0%

Subtask #3:

score: 0
Wrong Answer

Test #36:

score: 9
Accepted
time: 51ms
memory: 7328kb

input:

150000
3 3 1
2 5 5
1 3 5
4 3 5
3 4 4
4 4 2
4 3 5
5 1 2
5 4 1
2 3 3
4 4 5
3 3 5
2 4 3
1 3 2
5 2 4
4 5 3
2 5 1
5 4 3
3 2 5
1 1 4
3 2 5
2 3 5
3 3 4
1 3 4
2 4 3
1 5 4
2 1 4
1 4 4
5 4 3
4 5 3
2 1 2
5 4 5
4 5 4
5 1 2
1 4 1
3 1 4
2 5 2
3 5 3
3 4 2
5 1 4
5 2 1
1 2 2
1 3 2
5 4 3
5 4 5
3 2 4
5 5 2
5 3 3
3 4 4...

output:

15

result:

ok single line: '15'

Test #37:

score: -9
Wrong Answer
time: 33ms
memory: 5588kb

input:

99999
1 1 2
2 4 1
2 4 5
3 4 5
1 5 5
4 2 5
1 1 2
2 4 2
2 4 4
3 4 2
4 4 5
2 4 4
1 2 2
1 1 2
1 2 1
1 5 5
1 1 1
5 3 5
2 4 1
1 4 4
2 5 5
1 1 2
3 4 4
2 4 2
4 2 5
3 3 4
1 2 2
4 5 3
3 4 2
4 5 3
2 4 5
1 1 1
3 4 4
2 4 1
1 1 1
3 5 5
3 4 1
2 4 2
3 4 5
1 2 2
1 2 1
4 4 4
1 1 1
2 1 4
1 4 5
3 5 5
2 4 5
3 4 5
3 3 4
...

output:

15

result:

wrong answer 1st lines differ - expected: '8', found: '15'

Subtask #4:

score: 0
Skipped

Dependency #3:

0%

Subtask #5:

score: 0
Skipped

Dependency #4:

0%

Subtask #6:

score: 0
Skipped

Dependency #5:

0%

Subtask #7:

score: 0
Skipped

Dependency #1:

0%