Submission #84704

# Submission time Handle Problem Language Result Execution time Memory
84704 2018-11-16T19:19:22 Z updown1 Ice Hockey World Championship (CEOI15_bobek) C++17
100 / 100
515 ms 21636 KB
/*
come up with all combinations of money for the left and right half
count the total ways by binary searching the right values for each left value
*/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i, a, b) for(int i=a; i<b; i++)
#define ffi For(i, 0, N)
#define ffj For(j, 0, K)
#define ffa ffi ffj
#define s <<" "<<
#define c <<" : "<<
#define w cout
#define e endl//"\n"
#define pb push_back
#define mp make_pair
#define a first
#define b second
#define int ll
//500,000,000 operations
const int MAXN = 40, INF = 1000000000;
//Global Variables
int N, M, inp[MAXN], out;
vector<int> le, ri;

main() {
	//ifstream cin("test.in");
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin >> N >> M;
    ffi cin >> inp[i];
    le.pb(0), ri.pb(0);
    For (i, 0, N/2) {
        /// left half
        for (int j=le.size()-1; j>=0; j--) le.pb(le[j]+inp[i]);
    }
    //for (int i: le) w<< i<< " "; w<<e;
    For (i, N/2, N) {
        /// right half
        for (int j=ri.size()-1; j>=0; j--) ri.pb(ri[j]+inp[i]);
    }
    //for (int i: ri) w<< i<< " "; w<<e;
    /// combine left and right sides
    sort(ri.begin(), ri.end());
    for (int i: le) {
        if (i > M) continue;
        /// find biggest val in right s.t. i+val <= M, no edge cases bc 0 is a value
        int a = 0, b = ri.size()-1;
        while (a != b) {
            int mid = (a+b+1)/2;
            if (i+ri[mid] <= M) a = mid;
            else b = mid-1;
        }
        out += a+1;
    }
    w<< out<<e;
}

Compilation message

bobek.cpp:27:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main() {
      ^
# Verdict Execution time Memory Grader output
1 Correct 2 ms 504 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 504 KB Output is correct
2 Correct 2 ms 596 KB Output is correct
3 Correct 2 ms 644 KB Output is correct
4 Correct 2 ms 792 KB Output is correct
5 Correct 3 ms 792 KB Output is correct
6 Correct 2 ms 792 KB Output is correct
7 Correct 2 ms 792 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 792 KB Output is correct
2 Correct 2 ms 792 KB Output is correct
3 Correct 2 ms 792 KB Output is correct
4 Correct 2 ms 792 KB Output is correct
5 Correct 2 ms 792 KB Output is correct
6 Correct 2 ms 808 KB Output is correct
7 Correct 2 ms 812 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 816 KB Output is correct
2 Correct 2 ms 820 KB Output is correct
3 Correct 2 ms 828 KB Output is correct
4 Correct 2 ms 956 KB Output is correct
5 Correct 2 ms 956 KB Output is correct
6 Correct 2 ms 956 KB Output is correct
7 Correct 2 ms 956 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 28 ms 2520 KB Output is correct
2 Correct 99 ms 5972 KB Output is correct
3 Correct 515 ms 21392 KB Output is correct
4 Correct 98 ms 21392 KB Output is correct
5 Correct 11 ms 21392 KB Output is correct
6 Correct 6 ms 21392 KB Output is correct
7 Correct 9 ms 21392 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 40 ms 21392 KB Output is correct
2 Correct 28 ms 21392 KB Output is correct
3 Correct 187 ms 21392 KB Output is correct
4 Correct 2 ms 21392 KB Output is correct
5 Correct 5 ms 21392 KB Output is correct
6 Correct 11 ms 21392 KB Output is correct
7 Correct 9 ms 21392 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 55 ms 21392 KB Output is correct
2 Correct 134 ms 21392 KB Output is correct
3 Correct 135 ms 21392 KB Output is correct
4 Correct 2 ms 21392 KB Output is correct
5 Correct 47 ms 21392 KB Output is correct
6 Correct 171 ms 21392 KB Output is correct
7 Correct 59 ms 21392 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 285 ms 21392 KB Output is correct
2 Correct 26 ms 21392 KB Output is correct
3 Correct 10 ms 21392 KB Output is correct
4 Correct 2 ms 21392 KB Output is correct
5 Correct 6 ms 21392 KB Output is correct
6 Correct 152 ms 21392 KB Output is correct
7 Correct 8 ms 21392 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 28 ms 21392 KB Output is correct
2 Correct 91 ms 21392 KB Output is correct
3 Correct 10 ms 21392 KB Output is correct
4 Correct 11 ms 21392 KB Output is correct
5 Correct 77 ms 21392 KB Output is correct
6 Correct 18 ms 21392 KB Output is correct
7 Correct 132 ms 21512 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 344 ms 21636 KB Output is correct
2 Correct 30 ms 21636 KB Output is correct
3 Correct 11 ms 21636 KB Output is correct
4 Correct 475 ms 21636 KB Output is correct
5 Correct 79 ms 21636 KB Output is correct
6 Correct 11 ms 21636 KB Output is correct
7 Correct 16 ms 21636 KB Output is correct