Submission #369147

# Submission time Handle Problem Language Result Execution time Memory
369147 2021-02-20T14:34:24 Z doowey Table Tennis (info1cup20_tabletennis) C++14
15 / 100
54 ms 12252 KB
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;

#define fi first
#define se second
#define mp make_pair
#define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

struct item{
    int val;
    int ii;
    int jj;
    bool operator< (const item &ff) const {
        return val < ff.val;
    }
};

const int N = 150710;
int dp[N];
int las[N];
vector<int> T[N];

int main(){
    fastIO;
    int n,k;
    cin >> n >> k;
    vector<int> q(n + k);
    for(int i = 0 ;i < n + k; i ++ )
        cin >> q[i];
    sort(q.begin(), q.end());
    vector<item> pq;
    int m = n + k;
    for(int i = 0 ; i < m; i ++ ){
        for(int j = 1 ; j <= k + 1; j ++ ){
            if(i + j < m){
                pq.push_back({q[i + j] - q[i], i, i + j});
            }
        }
    }
    sort(pq.begin(), pq.end());
    vector<pii> cc;
    int cur;
    int go;
    vector<int> sol;
    for(int i = 0 ;i < pq.size(); i ++ ){
        cc.push_back(mp(pq[i].ii, pq[i].jj));
        if(i + 1 == pq.size() || pq[i].val != pq[i + 1].val){
            if(cc.size() >= n/2){
                for(int i = 0 ; i < m ; i ++ ){
                    dp[i]=0;
                    las[i]=-2;
                    T[i].clear();
                }
                for(auto x : cc){
                    T[x.se].push_back(x.fi);
                }
                for(int i = 0 ; i < m ; i ++ ){
                    dp[i]=dp[i-1];
                    for(auto x : T[i]){
                        cur = 1;
                        if(x > 0){
                            cur += dp[x - 1];
                        }
                        if(cur > dp[i]){
                            dp[i] = cur;
                            las[i] = x-1;
                        }
                    }
                }
                if(dp[m - 1] >= n/2){
                    go = m - 1;
                    while(sol.size() < n){
                        if(las[go] == -2){
                            go -- ;
                        }
                        else{
                            sol.push_back(go);
                            sol.push_back(las[go] + 1);
                            go = las[go];
                        }
                    }
                    sort(sol.begin(), sol.end());
                    for(auto x : sol)
                        cout << q[x] << " ";
                    cout << "\n";
                    return 0;
                }

            }
            cc.clear();
        }
    }
    return 0;
}

Compilation message

tabletennis.cpp: In function 'int main()':
tabletennis.cpp:49:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<item>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   49 |     for(int i = 0 ;i < pq.size(); i ++ ){
      |                    ~~^~~~~~~~~~~
tabletennis.cpp:51:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<item>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   51 |         if(i + 1 == pq.size() || pq[i].val != pq[i + 1].val){
      |            ~~~~~~^~~~~~~~~~~~
tabletennis.cpp:52: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]
   52 |             if(cc.size() >= n/2){
      |                ~~~~~~~~~~^~~~~~
tabletennis.cpp:76:38: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   76 |                     while(sol.size() < n){
      |                           ~~~~~~~~~~~^~~
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 3948 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 11 ms 5732 KB Output is correct
2 Incorrect 54 ms 12252 KB Unexpected end of file - int32 expected
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 45 ms 10716 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 4204 KB Output is correct
2 Correct 4 ms 4204 KB Output is correct
3 Correct 4 ms 4204 KB Output is correct
4 Correct 4 ms 4204 KB Output is correct
5 Correct 4 ms 4204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 3820 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 3948 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 3948 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 12 ms 5608 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -