답안 #314983

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
314983 2020-10-21T19:45:13 Z mohamedsobhi777 Ice Hockey World Championship (CEOI15_bobek) C++14
50 / 100
366 ms 33344 KB
#include <bits/stdc++.h>

#pragma GCC optimize("-Ofast")
//#pragma GCC optimize("trapv")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,sse4.2,popcnt,abm,mmx,avx2,tune=native")
#pragma GCC optimize("-ffast-math")
#pragma GCC optimize("-funroll-loops")

#define I inline void
#define S struct
#define vi vector<int>
#define vii vector<pair<int, int>>
#define pii pair<int, int>
#define pll pair<ll, ll>

using namespace std;
using ll = long long;
using ld = long double;

const int N = 2e5 + 7, mod = 1e9 + 7;
const ll inf = 2e18;

// How interesting!

ll n, m;

void make(vector<ll> &v)
{
        vector<ll> ret;
        int sz = (int)v.size();
        for (int i = 0; i < (1 << sz); ++i)
        {
                ll sum = 0;
                for (int j = 0; j < sz; ++j)
                {
                        if (i & (1 << j))
                        {
                                sum += v[j];
                        }
                }
                ret.push_back(sum);
        }
        sort(ret.begin(), ret.end());
        v = ret;
}

int main()
{
        ios_base::sync_with_stdio(0);
        cin.tie(0);
        //freopen("in.in", "r", stdin);
        cin >> n >> m;
        vector<ll> lhs, rhs;
        for (int i = 0; i < n; ++i)
        {
                int x;
                cin >> x;
                if (i < n / 2)
                        lhs.push_back(x);
                else
                        rhs.push_back(x);
        }
        make(lhs);
        make(rhs);
        ll ans = 0;
        int j = (int)rhs.size() - 1;
        for (int i = 0; i < (int)lhs.size(); ++i)
        {
                while (j >= 0 && lhs[i] + rhs[j] > m)
                        --j;
                ans += j + 1;
        }
        cout << ans;
        return 0;
}

/*
        - bounds sir (segtree = 4N, eulerTour = 2N, ...)
        - a variable defined twice?
        - will overflow?
        - is it a good complexity?
        - don't mess up indices (0-indexed vs 1-indexed)
        - reset everything between testcases. 
*/
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 0 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 29 ms 3056 KB Output is correct
2 Correct 87 ms 8544 KB Output is correct
3 Correct 366 ms 33344 KB Output is correct
4 Correct 85 ms 8544 KB Output is correct
5 Correct 15 ms 2424 KB Output is correct
6 Correct 10 ms 1404 KB Output is correct
7 Correct 20 ms 2424 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 40 ms 4460 KB Output is correct
2 Correct 31 ms 3056 KB Output is correct
3 Correct 149 ms 16724 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 7 ms 1404 KB Output is correct
6 Correct 20 ms 2424 KB Output is correct
7 Correct 19 ms 2424 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 61 ms 5604 KB Output is correct
2 Correct 130 ms 10760 KB Output is correct
3 Correct 128 ms 10716 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 88 ms 10844 KB Output is correct
6 Correct 315 ms 33296 KB Output is correct
7 Correct 130 ms 10720 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 172 ms 21056 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 20 ms 3064 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 227 ms 33156 KB Output isn't correct
2 Halted 0 ms 0 KB -