Submission #54620933


Source Code Expand

#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <functional>
#include <atcoder/all>
using namespace std;
using namespace atcoder;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

using mint = modint998244353;

int main(void) {
    int n, m;
    cin >> n >> m;
    VL a(n), b(m);
    REP(i,n) a[i] = in();
    REP(i,m) b[i] = in();
    sort(ALL(a));
    sort(ALL(b));
    int i = 0;
    ll ans = 0;
    REP(j,m){
        while (i < n && a[i] < b[j]) i++;
        if (i == n) {
            cout << -1 << endl;
            return 0;
        }
        ans += a[i];
        i++;
    }
    cout << ans << endl;
    return 0;
}

Submission Info

Submission Time
Task D - Souvenirs
User TangentDay
Language C++ 20 (gcc 12.2)
Score 350
Code Size 1477 Byte
Status AC
Exec Time 68 ms
Memory 6372 KiB

Compile Error

Main.cpp: In function ‘int in()’:
Main.cpp:39:24: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   39 | int in() { int x; scanf("%d", &x); return x; }
      |                   ~~~~~^~~~~~~~~~
Main.cpp: In function ‘ll lin()’:
Main.cpp:40:23: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   40 | ll lin() { ll x; scanf("%lld", &x); return x; }
      |                  ~~~~~^~~~~~~~~~~~

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 350 / 350
Status
AC × 3
AC × 33
Set Name Test Cases
Sample sample00.txt, sample01.txt, sample02.txt
All sample00.txt, sample01.txt, sample02.txt, testcase00.txt, testcase01.txt, testcase02.txt, testcase03.txt, testcase04.txt, testcase05.txt, testcase06.txt, testcase07.txt, testcase08.txt, testcase09.txt, testcase10.txt, testcase11.txt, testcase12.txt, testcase13.txt, testcase14.txt, testcase15.txt, testcase16.txt, testcase17.txt, testcase18.txt, testcase19.txt, testcase20.txt, testcase21.txt, testcase22.txt, testcase23.txt, testcase24.txt, testcase25.txt, testcase26.txt, testcase27.txt, testcase28.txt, testcase29.txt
Case Name Status Exec Time Memory
sample00.txt AC 1 ms 3648 KiB
sample01.txt AC 1 ms 3736 KiB
sample02.txt AC 1 ms 3700 KiB
testcase00.txt AC 24 ms 5556 KiB
testcase01.txt AC 32 ms 6048 KiB
testcase02.txt AC 19 ms 5056 KiB
testcase03.txt AC 31 ms 6292 KiB
testcase04.txt AC 29 ms 5736 KiB
testcase05.txt AC 30 ms 6112 KiB
testcase06.txt AC 49 ms 5460 KiB
testcase07.txt AC 8 ms 3732 KiB
testcase08.txt AC 44 ms 5376 KiB
testcase09.txt AC 6 ms 4052 KiB
testcase10.txt AC 63 ms 6056 KiB
testcase11.txt AC 1 ms 3648 KiB
testcase12.txt AC 36 ms 4732 KiB
testcase13.txt AC 27 ms 4584 KiB
testcase14.txt AC 67 ms 6264 KiB
testcase15.txt AC 10 ms 3728 KiB
testcase16.txt AC 67 ms 6372 KiB
testcase17.txt AC 14 ms 3780 KiB
testcase18.txt AC 55 ms 5760 KiB
testcase19.txt AC 10 ms 3832 KiB
testcase20.txt AC 39 ms 5180 KiB
testcase21.txt AC 20 ms 4268 KiB
testcase22.txt AC 55 ms 5992 KiB
testcase23.txt AC 13 ms 3800 KiB
testcase24.txt AC 40 ms 5080 KiB
testcase25.txt AC 14 ms 4016 KiB
testcase26.txt AC 67 ms 6288 KiB
testcase27.txt AC 51 ms 5568 KiB
testcase28.txt AC 68 ms 6372 KiB
testcase29.txt AC 60 ms 6092 KiB