提出 #54597481
ソースコード 拡げる
#include<bits/stdc++.h>
#include<functional>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
typedef __gnu_pbds::tree<long long, __gnu_pbds::null_type, less_equal<long long>, __gnu_pbds::rb_tree_tag, __gnu_pbds::tree_order_statistics_node_update> ordered_set;
// ordered set :two additional operations in log(n)
// order_of_key: The number of items in a set that are strictly smaller than k
// find_by_order: It returns an iterator to the ith largest element
const int MOD = 998244353;
const long long INF = 1e18;
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
#define float long double
#define vi vector<long long>
#define pb push_back
#define mii map<long long,long long>
#define pii pair<long long ,long long>
#define x first
#define y second
#define fr(i,b) for(long long i=0;i<b;i++)
#define frr(i,a,b) for(long long i=a;i<b;i++)
#define frn for(long long i=0;i<n;i++)
#define nl '\n'
#define all(x) (x).begin(), (x).end()
template <typename T>
istream& operator>> (istream& in, vector<T>& a)
{
for (int i = 0; i < a.size(); ++i)
in >> a[i];
return in;
}
template <typename T>
ostream& operator<< (ostream& out, vector<T>& a)
{
for (int i = 0; i < a.size(); ++i)
out << a[i] << " ";
out << "\n";
return out;
}
int binpow(int a, int b, long long m = INF){
a %= m;
int res = 1;
while (b > 0){
if (b & 1) res = res * a % m;
a = a * a % m;
b >>= 1;
}
return res;
}
set<int>primes;
void sieve(int n){
bool prime[n + 1];
memset(prime, true, sizeof(prime));
for (int p = 2; p * p <= n; p++)
if (prime[p] == true)
for (int i = p * p; i <= n; i += p) prime[i] = false;
for (int p = 2; p <= n; p++) if (prime[p]) primes.insert(p);
}
int modinv(int x){
return(binpow(x,MOD-2));
}
void solve(){
int m,n;
cin>>m>>n;
vi a(m),b(n);
cin>>a>>b;
sort(all(b),greater<int>());
set<int> st;
fr(i,m) st.insert(a[i]);
int ans = 0;
frn{
auto ind = st.lower_bound(b[i]);
if(ind == st.end()){
cout<<-1<<nl;
return;
}
ans+= *ind;
st.erase(ind);
}
cout<<ans<<nl;
}
signed main(){
fast_io;
int T = 1;
// cin>>T;
while(T--){
solve();
}
return 0;
}
提出情報
| 提出日時 | |
|---|---|
| 問題 | D - Souvenirs |
| ユーザ | ananthak |
| 言語 | C++ 20 (gcc 12.2) |
| 得点 | 0 |
| コード長 | 2534 Byte |
| 結果 | WA |
| 実行時間 | 105 ms |
| メモリ | 15492 KiB |
コンパイルエラー
Main.cpp: In instantiation of ‘std::istream& operator>>(std::istream&, std::vector<_Tp>&) [with T = long long int; std::istream = std::basic_istream<char>]’:
Main.cpp:73:10: required from here
Main.cpp:31:23: warning: comparison of integer expressions of different signedness: ‘long long int’ and ‘std::vector<long long int>::size_type’ {aka ‘long unsigned int’} [-Wsign-compare]
31 | for (int i = 0; i < a.size(); ++i)
| ~~^~~~~~~~~~
ジャッジ結果
| セット名 | Sample | All | ||||||
|---|---|---|---|---|---|---|---|---|
| 得点 / 配点 | 0 / 0 | 0 / 350 | ||||||
| 結果 |
|
|
| セット名 | テストケース |
|---|---|
| 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 |
| ケース名 | 結果 | 実行時間 | メモリ |
|---|---|---|---|
| sample00.txt | AC | 1 ms | 3424 KiB |
| sample01.txt | AC | 1 ms | 3484 KiB |
| sample02.txt | AC | 1 ms | 3420 KiB |
| testcase00.txt | WA | 18 ms | 5384 KiB |
| testcase01.txt | WA | 23 ms | 5912 KiB |
| testcase02.txt | WA | 14 ms | 4928 KiB |
| testcase03.txt | WA | 24 ms | 6172 KiB |
| testcase04.txt | AC | 21 ms | 5640 KiB |
| testcase05.txt | AC | 22 ms | 5984 KiB |
| testcase06.txt | WA | 86 ms | 14688 KiB |
| testcase07.txt | WA | 9 ms | 4704 KiB |
| testcase08.txt | WA | 81 ms | 14356 KiB |
| testcase09.txt | AC | 7 ms | 4352 KiB |
| testcase10.txt | WA | 98 ms | 15412 KiB |
| testcase11.txt | AC | 1 ms | 3588 KiB |
| testcase12.txt | AC | 77 ms | 14168 KiB |
| testcase13.txt | AC | 45 ms | 10716 KiB |
| testcase14.txt | WA | 105 ms | 15404 KiB |
| testcase15.txt | AC | 12 ms | 4852 KiB |
| testcase16.txt | WA | 102 ms | 15492 KiB |
| testcase17.txt | AC | 16 ms | 5636 KiB |
| testcase18.txt | AC | 79 ms | 14920 KiB |
| testcase19.txt | AC | 15 ms | 5984 KiB |
| testcase20.txt | WA | 74 ms | 14256 KiB |
| testcase21.txt | AC | 29 ms | 7788 KiB |
| testcase22.txt | AC | 79 ms | 14980 KiB |
| testcase23.txt | AC | 14 ms | 5812 KiB |
| testcase24.txt | AC | 71 ms | 14352 KiB |
| testcase25.txt | AC | 18 ms | 5920 KiB |
| testcase26.txt | AC | 87 ms | 15468 KiB |
| testcase27.txt | AC | 64 ms | 12764 KiB |
| testcase28.txt | AC | 90 ms | 15488 KiB |
| testcase29.txt | AC | 75 ms | 14404 KiB |