답안 #992646

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
992646 2024-06-04T23:31:09 Z amin_2008 A Difficult(y) Choice (BOI21_books) C++17
0 / 100
4 ms 1212 KB
#include <iostream>
#include <fstream>
#include <cstdio>
#include <queue>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <map>
#include <cassert>
#include <unordered_map>
#include <set>
#include <stack>
#include <cstring>
#include <cmath>
#include <bitset>
#include <random>
#include <numeric>
#include <cstdlib> 

#include "books.h"

using namespace std;
//
// --- Sample implementation for the task books ---
//
// To compile this program with the sample grader, place:
//     books.h books_sample.cpp sample_grader.cpp
// in a single folder and run:
//     g++ books_sample.cpp sample_grader.cpp
// in this folder.
//

void solve(int N, int K, long long A, int S) 
{
    int lg[N + 5];
    lg[1] = 0;
    for(int i = 2; i < N + 5; i++) lg[i] = lg[i >> 1] + 1;
    int a[N + 5];
    for(int i = 1; i <= N; i++) a[i] = skim(i);
    vector<vector<int > > mat;
    mat.assign(lg[N] + 1, vector<int>(N + 1, 0));
    for(int i = 1; i <= N; i++) mat[0][i] = a[i];
    for(int i = 1; i <= lg[N]; i++) for(int j = 1; j + (1LL << i) <= N; j++) mat[i][j] = mat[i - 1][j] + mat[i - 1][j + (1LL << (i - 1))];
    for(int i = 1; i <= N; i++) 
    {
        if (mat[lg[(i + K - 1) - i + 1]][i] + mat[lg[(i + K - 1) - i + 1]][(i + K - 1) - (1LL << lg[(i + K - 1) - i + 1]) + 1] >= A 
        and 
        mat[lg[(i + K - 1) - i + 1]][i] + mat[lg[(i + K - 1) - i + 1]][(i + K - 1) - (1LL << lg[(i + K - 1) - i + 1]) + 1] <= 2 * A) 
        {
            vector<int> res;
            for(int j = i; j <= i + K - 1; j++) res.push_back(a[j]);
            answer(res);
            return;
        }
    }
    impossible();
}

// 15 3 42 15
// 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21   
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 344 KB Incorrect
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 344 KB Incorrect
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 4 ms 1212 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 4 ms 1212 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 4 ms 1212 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 4 ms 1212 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 4 ms 1212 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -