Submission #49053194


Source Code Expand

#include "atcoder/all"
#include <boost/multiprecision/cpp_int.hpp>
#include <cmath>
#include <stack>
#include <set>
#include <map>
#include <bitset>

using namespace std;
using namespace atcoder;

using lint = long long int;
using mint = atcoder::modint;
using bint = boost::multiprecision::cpp_int;

template<typename T>
inline bool chmin(T &a, const T b) {return a > b && (a = b, true);}
template<typename T>
inline bool chmax(T &a, const T b) {return a < b && (a = b, true);}

template <typename T>
int lb(const std::vector<T> &v, const T &x) { return std::distance(v.begin(), std::lower_bound(v.begin(), v.end(), x)); }
template <typename T>
int ub(const std::vector<T> &v, const T &x) { return std::distance(v.begin(), std::upper_bound(v.begin(), v.end(), x)); }

template<typename T>
std::istream &operator>>(std::istream &is, std::vector<T> &v) { for(T &e: v) is >> e; return is; }
template<typename T>
std::ostream &operator<<(std::ostream &os, const std::vector<T> &v) { for(size_t i=0; i<v.size(); i++) { os << v[i] << (i+1 == v.size() ? '\n' : ' '); } return os; }

template<typename T>
std::vector<T> &operator++(std::vector<T> &v) { for(auto&& e: v) {++e;} return v; }
template<typename T>
std::vector<T> &operator--(std::vector<T> &v) { for(auto&& e: v) {--e;} return v; }

int main(void) {
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);

    int N;
    cin >> N;
    vector<int> A(N);
    cin >> A;

    if(N > 100 || *max_element(A.begin(), A.end()) > 100) abort();

    vector<lint> v;

    for(int m=1; m<=100; m++) {
        int ans1 = *max_element(A.begin(), A.end()) % m;
        int ans2 = 0;
        for(int j=0; j<N; j++) {
            chmax(ans2, A[j]%m);
        }
        if(ans1 != ans2) v.emplace_back(m);
    }

    int Q;
    cin >> Q;
    while(Q--) {
        lint M;
        cin >> M;
        cout << M - ub(v, M) << endl;
    }
    return 0;
}

Submission Info

Submission Time
Task F - Remainder of Max Problem
User hasegawa1
Language C++ 23 (gcc 12.2)
Score 1
Code Size 1955 Byte
Status RE
Exec Time 204 ms
Memory 4072 KiB

Judge Result

Set Name Sample Subtask1 All
Score / Max Score 0 / 0 1 / 1 0 / 99
Status
AC × 2
AC × 21
AC × 21
RE × 25
Set Name Test Cases
Sample 00_sample_1.txt, 00_sample_2.txt
Subtask1 00_sample_1.txt, 00_sample_2.txt, 02random_small_1.txt, 02random_small_10.txt, 02random_small_11.txt, 02random_small_12.txt, 02random_small_13.txt, 02random_small_14.txt, 02random_small_15.txt, 02random_small_2.txt, 02random_small_3.txt, 02random_small_4.txt, 02random_small_5.txt, 02random_small_6.txt, 02random_small_7.txt, 02random_small_8.txt, 02random_small_9.txt, 03handmade1.txt, 03handmade2.txt, 03handmade4.txt, 03handmade5.txt
All 00_sample_1.txt, 00_sample_2.txt, 01random_1.txt, 01random_10.txt, 01random_11.txt, 01random_12.txt, 01random_13.txt, 01random_14.txt, 01random_15.txt, 01random_16.txt, 01random_17.txt, 01random_18.txt, 01random_19.txt, 01random_2.txt, 01random_20.txt, 01random_3.txt, 01random_4.txt, 01random_5.txt, 01random_6.txt, 01random_7.txt, 01random_8.txt, 01random_9.txt, 02random_small_1.txt, 02random_small_10.txt, 02random_small_11.txt, 02random_small_12.txt, 02random_small_13.txt, 02random_small_14.txt, 02random_small_15.txt, 02random_small_2.txt, 02random_small_3.txt, 02random_small_4.txt, 02random_small_5.txt, 02random_small_6.txt, 02random_small_7.txt, 02random_small_8.txt, 02random_small_9.txt, 03handmade1.txt, 03handmade2.txt, 03handmade3.txt, 03handmade4.txt, 03handmade5.txt, 03handmade6.txt, 03handmade7.txt, 03handmade8.txt, 03handmade9.txt
Case Name Status Exec Time Memory
00_sample_1.txt AC 1 ms 3472 KiB
00_sample_2.txt AC 1 ms 3452 KiB
01random_1.txt RE 76 ms 3264 KiB
01random_10.txt RE 81 ms 4020 KiB
01random_11.txt RE 75 ms 3300 KiB
01random_12.txt RE 75 ms 3248 KiB
01random_13.txt RE 75 ms 3240 KiB
01random_14.txt RE 75 ms 3288 KiB
01random_15.txt RE 76 ms 3380 KiB
01random_16.txt RE 76 ms 3356 KiB
01random_17.txt RE 77 ms 3328 KiB
01random_18.txt RE 82 ms 4072 KiB
01random_19.txt RE 81 ms 3832 KiB
01random_2.txt RE 74 ms 3224 KiB
01random_20.txt RE 76 ms 3540 KiB
01random_3.txt RE 75 ms 3248 KiB
01random_4.txt RE 76 ms 3416 KiB
01random_5.txt RE 76 ms 3308 KiB
01random_6.txt RE 83 ms 4024 KiB
01random_7.txt RE 82 ms 3996 KiB
01random_8.txt RE 83 ms 4052 KiB
01random_9.txt RE 83 ms 4032 KiB
02random_small_1.txt AC 204 ms 3536 KiB
02random_small_10.txt AC 1 ms 3468 KiB
02random_small_11.txt AC 203 ms 3420 KiB
02random_small_12.txt AC 1 ms 3464 KiB
02random_small_13.txt AC 194 ms 3628 KiB
02random_small_14.txt AC 10 ms 3536 KiB
02random_small_15.txt AC 1 ms 3360 KiB
02random_small_2.txt AC 1 ms 3360 KiB
02random_small_3.txt AC 68 ms 3480 KiB
02random_small_4.txt AC 142 ms 3316 KiB
02random_small_5.txt AC 1 ms 3492 KiB
02random_small_6.txt AC 201 ms 3476 KiB
02random_small_7.txt AC 27 ms 3484 KiB
02random_small_8.txt AC 84 ms 3568 KiB
02random_small_9.txt AC 126 ms 3432 KiB
03handmade1.txt AC 199 ms 3616 KiB
03handmade2.txt AC 199 ms 3568 KiB
03handmade3.txt RE 75 ms 3232 KiB
03handmade4.txt AC 76 ms 3536 KiB
03handmade5.txt AC 1 ms 3476 KiB
03handmade6.txt RE 76 ms 3232 KiB
03handmade7.txt RE 80 ms 3948 KiB
03handmade8.txt RE 81 ms 4012 KiB
03handmade9.txt RE 83 ms 3952 KiB