답안 #86599

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
86599 2018-11-26T22:25:47 Z rzbt Ice Hockey World Championship (CEOI15_bobek) C++14
100 / 100
403 ms 21424 KB
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define MAXN 100005
typedef long long ll;
using namespace std;

ll n,m;
vector<ll> tekme1,tekme2,svi1,svi2;

using namespace std;

int main()
{
    scanf("%lld %lld", &n, &m);
    for(int i=0;i<n;i++){
        ll t;
        scanf("%lld", &t);
        if(i%2==0)tekme1.pb(t);
        else tekme2.pb(t);
    }
    int gran=1<<tekme1.size();
    for(int i=0;i<gran;i++){
        ll ts=0;
        for(int j=0;j<tekme1.size();j++){
            if((i>>j)&1)ts+=tekme1[j];
        }
        svi1.pb(ts);
    }
    gran=1<<tekme2.size();
    for(int i=0;i<gran;i++){
        ll ts=0;
        for(int j=0;j<tekme2.size();j++){
            if((i>>j)&1)ts+=tekme2[j];
        }
        svi2.pb(ts);
    }
    sort(all(svi1));
    sort(all(svi2));
    ll j=svi2.size()-1,res=0;
    for(ll i=0;i<svi1.size();i++){
        while(svi1[i]+svi2[j]>m && j>=0)j--;
        //printf("%lld %lld\n",i,j);
        if(j==-1)break;
        res+=j+1ll;
    }
    printf("%lld",res);
    return 0;
}

Compilation message

bobek.cpp: In function 'int main()':
bobek.cpp:28:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for(int j=0;j<tekme1.size();j++){
                     ~^~~~~~~~~~~~~~
bobek.cpp:36:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for(int j=0;j<tekme2.size();j++){
                     ~^~~~~~~~~~~~~~
bobek.cpp:44:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(ll i=0;i<svi1.size();i++){
                ~^~~~~~~~~~~~
bobek.cpp:18:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%lld %lld", &n, &m);
     ~~~~~^~~~~~~~~~~~~~~~~~~~~
bobek.cpp:21:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%lld", &t);
         ~~~~~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 400 KB Output is correct
3 Correct 2 ms 480 KB Output is correct
4 Correct 2 ms 480 KB Output is correct
5 Correct 2 ms 564 KB Output is correct
6 Correct 2 ms 564 KB Output is correct
7 Correct 2 ms 588 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 588 KB Output is correct
2 Correct 2 ms 708 KB Output is correct
3 Correct 2 ms 708 KB Output is correct
4 Correct 2 ms 708 KB Output is correct
5 Correct 2 ms 708 KB Output is correct
6 Correct 2 ms 708 KB Output is correct
7 Correct 2 ms 708 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 708 KB Output is correct
2 Correct 2 ms 708 KB Output is correct
3 Correct 3 ms 708 KB Output is correct
4 Correct 2 ms 708 KB Output is correct
5 Correct 2 ms 712 KB Output is correct
6 Correct 2 ms 712 KB Output is correct
7 Correct 2 ms 720 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 32 ms 2756 KB Output is correct
2 Correct 92 ms 5744 KB Output is correct
3 Correct 403 ms 21160 KB Output is correct
4 Correct 91 ms 21160 KB Output is correct
5 Correct 18 ms 21160 KB Output is correct
6 Correct 12 ms 21160 KB Output is correct
7 Correct 23 ms 21160 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 48 ms 21160 KB Output is correct
2 Correct 33 ms 21160 KB Output is correct
3 Correct 165 ms 21160 KB Output is correct
4 Correct 2 ms 21160 KB Output is correct
5 Correct 9 ms 21160 KB Output is correct
6 Correct 23 ms 21160 KB Output is correct
7 Correct 23 ms 21160 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 68 ms 21160 KB Output is correct
2 Correct 145 ms 21160 KB Output is correct
3 Correct 142 ms 21160 KB Output is correct
4 Correct 2 ms 21160 KB Output is correct
5 Correct 97 ms 21160 KB Output is correct
6 Correct 347 ms 21248 KB Output is correct
7 Correct 141 ms 21248 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 300 ms 21248 KB Output is correct
2 Correct 34 ms 21248 KB Output is correct
3 Correct 12 ms 21248 KB Output is correct
4 Correct 2 ms 21248 KB Output is correct
5 Correct 10 ms 21248 KB Output is correct
6 Correct 282 ms 21248 KB Output is correct
7 Correct 22 ms 21248 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 34 ms 21248 KB Output is correct
2 Correct 91 ms 21248 KB Output is correct
3 Correct 12 ms 21248 KB Output is correct
4 Correct 12 ms 21248 KB Output is correct
5 Correct 112 ms 21248 KB Output is correct
6 Correct 34 ms 21248 KB Output is correct
7 Correct 379 ms 21268 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 400 ms 21420 KB Output is correct
2 Correct 42 ms 21420 KB Output is correct
3 Correct 12 ms 21420 KB Output is correct
4 Correct 394 ms 21424 KB Output is correct
5 Correct 134 ms 21424 KB Output is correct
6 Correct 22 ms 21424 KB Output is correct
7 Correct 44 ms 21424 KB Output is correct