답안 #968530

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
968530 2024-04-23T14:44:31 Z vjudge1 Ice Hockey World Championship (CEOI15_bobek) C++17
100 / 100
289 ms 22192 KB
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;
using ll = long long;
const int N = 44;

ll n, m;
vector<ll> lv, rv;
vector<ll> la, ra;

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

int main()
{
    int n;
    ll k; scanf("%d %lld", &n, &k);;
    for (int i = 0;i < n/2;i++){
        ll v; scanf("%lld", &v);
        la.push_back(v);
    }
    for (int i = n/2;i < n;i++){
        ll v; scanf("%lld", &v);
        ra.push_back(v);
    }
    calc(la, lv);
    calc(ra, rv);
    ll p = 0ll, ans = 0ll;
    reverse(lv.begin(), lv.end());
    for (auto e:lv){
        while (p < rv.size() && rv[p]+e <= k) p++;
        ans += p;
    }
    printf("%lld", ans);
}

Compilation message

bobek.cpp: In function 'void calc(std::vector<long long int>&, std::vector<long long int>&)':
bobek.cpp:16:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   16 |         for (int j = 0;j < v.size();j++){
      |                        ~~^~~~~~~~~~
bobek.cpp: In function 'int main()':
bobek.cpp:41:18: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   41 |         while (p < rv.size() && rv[p]+e <= k) p++;
      |                ~~^~~~~~~~~~~
bobek.cpp:27:16: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   27 |     ll k; scanf("%d %lld", &n, &k);;
      |           ~~~~~^~~~~~~~~~~~~~~~~~~
bobek.cpp:29:20: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   29 |         ll v; scanf("%lld", &v);
      |               ~~~~~^~~~~~~~~~~~
bobek.cpp:33:20: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   33 |         ll v; scanf("%lld", &v);
      |               ~~~~~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 23 ms 1992 KB Output is correct
2 Correct 68 ms 5432 KB Output is correct
3 Correct 289 ms 21676 KB Output is correct
4 Correct 67 ms 5340 KB Output is correct
5 Correct 12 ms 1488 KB Output is correct
6 Correct 7 ms 984 KB Output is correct
7 Correct 15 ms 1492 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 31 ms 2944 KB Output is correct
2 Correct 24 ms 2132 KB Output is correct
3 Correct 117 ms 11704 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 6 ms 980 KB Output is correct
6 Correct 15 ms 1488 KB Output is correct
7 Correct 15 ms 1492 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 48 ms 3652 KB Output is correct
2 Correct 108 ms 8048 KB Output is correct
3 Correct 100 ms 7744 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 69 ms 6980 KB Output is correct
6 Correct 254 ms 21004 KB Output is correct
7 Correct 101 ms 8520 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 208 ms 13628 KB Output is correct
2 Correct 24 ms 2132 KB Output is correct
3 Correct 8 ms 1112 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 7 ms 984 KB Output is correct
6 Correct 205 ms 14360 KB Output is correct
7 Correct 15 ms 1492 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 24 ms 1876 KB Output is correct
2 Correct 66 ms 5316 KB Output is correct
3 Correct 8 ms 984 KB Output is correct
4 Correct 8 ms 980 KB Output is correct
5 Correct 74 ms 7748 KB Output is correct
6 Correct 23 ms 1880 KB Output is correct
7 Correct 271 ms 22192 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 282 ms 21164 KB Output is correct
2 Correct 24 ms 1880 KB Output is correct
3 Correct 8 ms 1108 KB Output is correct
4 Correct 289 ms 22192 KB Output is correct
5 Correct 98 ms 11756 KB Output is correct
6 Correct 15 ms 1488 KB Output is correct
7 Correct 33 ms 3024 KB Output is correct