Submission #67977258


Source Code Expand

// I AM A MUSLIM

#include "bits/stdc++.h"

#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")

#define fast_io std::ios::sync_with_stdio(0);std::cin.tie(0)
#define lli long long int
#define flush fflush(stdout)
#define line printf("\n")
#define yn(a, b) printf("%s\n", (a) >= (b) ? "Yes":"No")
#define amodm(a, M) (((a)%M+M)%M)
#define read(s) std::string s;std::cin >> s
#define readL(s) std::string s;getline(std::cin, s)
#define write(s) printf("%s\n", s.c_str())
// #define int lli

using pii = std::pair<int,int>;
const int MOD = 1000000007;
const int mxN = 500100;

signed main() {
    int testCases=1;
    scanf("%d",&testCases);
    
    for (int TC = 1; TC <= testCases; TC++) {
        int n, m;
        scanf("%d%d",&n,&m);
        std::vector<int> a(n); for (auto &i : a) scanf("%d",&i);
        // sort(a.begin(), a.end());
        std::multiset<int> b;
        for (int i = 0, v; i < n; i++) {
            scanf("%d",&v);
            b.insert(v);
        }
        lli ans = 0;
        for (auto &i : a) {
            int j = m-i;
            auto it = b.lower_bound(j);
            if (it == b.end()) {
                it = b.begin();
            }
            ans += (i+*it)%m;
            b.erase(it);
        }
        printf("%lld\n", ans);
    }
    
    return 0;
}

Submission Info

Submission Time
Task D - Match, Mod, Minimize 2
User MArhamAA1422
Language C++ 20 (gcc 12.2)
Score 400
Code Size 1375 Byte
Status AC
Exec Time 271 ms
Memory 18568 KiB

Compile Error

Main.cpp: In function ‘int main()’:
Main.cpp:25:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   25 |     scanf("%d",&testCases);
      |     ~~~~~^~~~~~~~~~~~~~~~~
Main.cpp:29:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   29 |         scanf("%d%d",&n,&m);
      |         ~~~~~^~~~~~~~~~~~~~
Main.cpp:30:55: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   30 |         std::vector<int> a(n); for (auto &i : a) scanf("%d",&i);
      |                                                  ~~~~~^~~~~~~~~
Main.cpp:34:18: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   34 |             scanf("%d",&v);
      |             ~~~~~^~~~~~~~~

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 400 / 400
Status
AC × 1
AC × 30
Set Name Test Cases
Sample 00_sample_00.txt
All 00_sample_00.txt, 01_handmade_00.txt, 01_handmade_01.txt, 01_handmade_02.txt, 01_handmade_03.txt, 01_handmade_04.txt, 01_handmade_05.txt, 02_random_00.txt, 02_random_01.txt, 02_random_02.txt, 02_random_03.txt, 02_random_04.txt, 02_random_05.txt, 02_random_06.txt, 02_random_07.txt, 02_random_08.txt, 02_random_09.txt, 02_random_10.txt, 02_random_11.txt, 02_random_12.txt, 02_random_13.txt, 02_random_14.txt, 02_random_15.txt, 02_random_16.txt, 02_random_17.txt, 02_random_18.txt, 02_random_19.txt, 02_random_20.txt, 02_random_21.txt, 02_random_22.txt
Case Name Status Exec Time Memory
00_sample_00.txt AC 1 ms 3876 KiB
01_handmade_00.txt AC 239 ms 18528 KiB
01_handmade_01.txt AC 134 ms 18560 KiB
01_handmade_02.txt AC 111 ms 18568 KiB
01_handmade_03.txt AC 271 ms 18512 KiB
01_handmade_04.txt AC 1 ms 3520 KiB
01_handmade_05.txt AC 32 ms 3620 KiB
02_random_00.txt AC 247 ms 18532 KiB
02_random_01.txt AC 256 ms 18496 KiB
02_random_02.txt AC 251 ms 18448 KiB
02_random_03.txt AC 243 ms 18568 KiB
02_random_04.txt AC 93 ms 3840 KiB
02_random_05.txt AC 93 ms 3680 KiB
02_random_06.txt AC 93 ms 3660 KiB
02_random_07.txt AC 94 ms 3784 KiB
02_random_08.txt AC 93 ms 3628 KiB
02_random_09.txt AC 93 ms 3648 KiB
02_random_10.txt AC 119 ms 4280 KiB
02_random_11.txt AC 119 ms 4032 KiB
02_random_12.txt AC 120 ms 4340 KiB
02_random_13.txt AC 118 ms 4376 KiB
02_random_14.txt AC 119 ms 4284 KiB
02_random_15.txt AC 118 ms 4128 KiB
02_random_16.txt AC 98 ms 3876 KiB
02_random_17.txt AC 93 ms 3644 KiB
02_random_18.txt AC 93 ms 3776 KiB
02_random_19.txt AC 93 ms 3840 KiB
02_random_20.txt AC 94 ms 3648 KiB
02_random_21.txt AC 94 ms 3892 KiB
02_random_22.txt AC 94 ms 3524 KiB