답안 #247389

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
247389 2020-07-11T10:07:31 Z _ash__ Sticks (POI11_pat) C++14
100 / 100
371 ms 22340 KB
#include <bits/stdc++.h>
using namespace std;

const int N = 1e6 + 100;

int main() {
    // freopen("in.txt", "r", stdin);
    ios::sync_with_stdio(0);
    cin.tie(0);

    int K;
    cin >> K;
    vector<vector<int>> col(K);
    vector<pair<int,int>> all;
    for(int i = 0; i < K; i++) {
        int n;
        cin >> n;
        while(n--) {
            int x;
            cin >> x;
            col[i].push_back(x);
            all.push_back({x, i});
        }
        sort(col[i].begin(), col[i].end());
    }
    sort(all.begin(), all.end());
    vector<int> best(K);
    for(int i = 0; i < all.size(); i++) {
        int a = 0, b = 0, col_a, col_b;
        int col_c = all[i].second;
        for(int j = 0; j < K; j++) {
            if(col_c == j) continue;
            int x = best[j];
            if(x > b) a = b, col_a = col_b, b = x, col_b = j;
            else if(x > a) col_a = j, a = x;
        }
        int c = all[i].first;
        if(a+b > c) {
            cout << col_a+1 << " " << a << " " << col_b+1 << " " << b << " " << col_c+1 << " " << c << endl;
            exit(0);
        }
        best[col_c] = c;
    }
    cout << "NIE" << endl;
    return 0;
}

Compilation message

pat.cpp: In function 'int main()':
pat.cpp:28:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i = 0; i < all.size(); i++) {
                    ~~^~~~~~~~~~~~
pat.cpp:39:32: warning: 'col_a' may be used uninitialized in this function [-Wmaybe-uninitialized]
             cout << col_a+1 << " " << a << " " << col_b+1 << " " << b << " " << col_c+1 << " " << c << endl;
                                ^~~
pat.cpp:39:62: warning: 'col_b' may be used uninitialized in this function [-Wmaybe-uninitialized]
             cout << col_a+1 << " " << a << " " << col_b+1 << " " << b << " " << col_c+1 << " " << c << endl;
                                                              ^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Oczekiwano NIE
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Oczekiwano NIE
2 Correct 13 ms 1116 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Oczekiwano NIE
2 Correct 17 ms 1384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 512 KB Oczekiwano NIE
2 Correct 35 ms 2552 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 12 ms 1024 KB Oczekiwano NIE
2 Correct 51 ms 4460 KB Output is correct
3 Correct 36 ms 2680 KB Oczekiwano NIE
# 결과 실행 시간 메모리 Grader output
1 Correct 26 ms 2296 KB Oczekiwano NIE
2 Correct 89 ms 8036 KB Output is correct
3 Correct 55 ms 4368 KB Oczekiwano NIE
# 결과 실행 시간 메모리 Grader output
1 Correct 171 ms 11608 KB Output is correct
2 Correct 107 ms 8164 KB Output is correct
3 Correct 82 ms 5836 KB Oczekiwano NIE
# 결과 실행 시간 메모리 Grader output
1 Correct 168 ms 11356 KB Output is correct
2 Correct 116 ms 8292 KB Output is correct
3 Correct 107 ms 8416 KB Oczekiwano NIE
# 결과 실행 시간 메모리 Grader output
1 Correct 343 ms 22340 KB Output is correct
2 Correct 134 ms 9440 KB Output is correct
3 Correct 161 ms 10592 KB Oczekiwano NIE
# 결과 실행 시간 메모리 Grader output
1 Correct 371 ms 22216 KB Output is correct
2 Correct 156 ms 10588 KB Output is correct
3 Correct 187 ms 15964 KB Oczekiwano NIE