Submission #43795858
Source Code Expand
// LUOGU_RID: 116739102
#include<cstdio>
#include<algorithm>
#include<set>
using namespace std;
#define Ls(i,l,r) for(int i=l;i<r;++i)
#define Rs(i,l,r) for(int i=l;i>r;--i)
#define Le(i,l,r) for(int i=l;i<=r;++i)
#define Re(i,l,r) for(int i=l;i>=r;--i)
#define L(i,l) for(int i=0;i<l;++i)
#define E(i,l) for(int i=1;i<=l;++i)
#define W(t) while(t--)
typedef long long ll;
const int N=200010;
int n,m;
ll sum;
multiset<int>s;
struct quan{
int l,d;
bool operator<(const quan&o)const{
return d>o.d;
}
}q[N];
int main(){
#ifndef ONLINE_JUDGE
freopen("1.in","r",stdin);
// freopen("my.txt","w",stdout);
// freopen("1.out","w",stdout);
// ios::sync_with_stdio(0);
// cin.tie(0);
// cout.tie(0);
#endif
// Insert Code Here
scanf("%d%d",&n,&m);
E(i, n){
int p;
scanf("%d",&p);
s.insert(p);
sum+=p;
}
// printf("%lld\n",sum);
E(i, m)scanf("%d",&q[i].l);
E(i, m)scanf("%d",&q[i].d);
sort(q+1,q+1+m);
E(i, m){
auto pos=s.lower_bound(q[i].l);
if(pos!=s.end()){
sum-=q[i].d;
s.erase(pos);
}
}
printf("%lld",sum);
return 0;
}
Submission Info
| Submission Time |
|
| Task |
F - Vouchers |
| User |
WUSICHENG |
| Language |
C++ (GCC 9.2.1) |
| Score |
500 |
| Code Size |
1244 Byte |
| Status |
AC |
| Exec Time |
241 ms |
| Memory |
14200 KiB |
Compile Error
./Main.cpp: In function ‘int main()’:
./Main.cpp:34:10: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
34 | scanf("%d%d",&n,&m);
| ~~~~~^~~~~~~~~~~~~~
./Main.cpp:37:14: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
37 | scanf("%d",&p);
| ~~~~~^~~~~~~~~
./Main.cpp:42:17: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
42 | E(i, m)scanf("%d",&q[i].l);
| ~~~~~^~~~~~~~~~~~~~
./Main.cpp:43:17: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
43 | E(i, m)scanf("%d",&q[i].d);
| ~~~~~^~~~~~~~~~~~~~
Judge Result
| Set Name |
Sample |
All |
| Score / Max Score |
0 / 0 |
500 / 500 |
| Status |
|
|
| Set Name |
Test Cases |
| Sample |
00_sample_01.txt, 00_sample_02.txt |
| All |
00_sample_01.txt, 00_sample_02.txt, 01_random_01.txt, 01_random_02.txt, 01_random_03.txt, 01_random_04.txt, 01_random_05.txt, 01_random_06.txt, 01_random_07.txt, 01_random_08.txt, 01_random_09.txt, 01_random_10.txt, 01_random_11.txt, 01_random_12.txt, 01_random_13.txt, 01_random_14.txt, 01_random_15.txt, 02_handmade_01.txt, 02_handmade_02.txt |
| Case Name |
Status |
Exec Time |
Memory |
| 00_sample_01.txt |
AC |
6 ms |
3204 KiB |
| 00_sample_02.txt |
AC |
3 ms |
3280 KiB |
| 01_random_01.txt |
AC |
2 ms |
3276 KiB |
| 01_random_02.txt |
AC |
65 ms |
7884 KiB |
| 01_random_03.txt |
AC |
108 ms |
9676 KiB |
| 01_random_04.txt |
AC |
55 ms |
6660 KiB |
| 01_random_05.txt |
AC |
105 ms |
11224 KiB |
| 01_random_06.txt |
AC |
231 ms |
14132 KiB |
| 01_random_07.txt |
AC |
214 ms |
14052 KiB |
| 01_random_08.txt |
AC |
220 ms |
14048 KiB |
| 01_random_09.txt |
AC |
219 ms |
14196 KiB |
| 01_random_10.txt |
AC |
213 ms |
14200 KiB |
| 01_random_11.txt |
AC |
217 ms |
14136 KiB |
| 01_random_12.txt |
AC |
214 ms |
14168 KiB |
| 01_random_13.txt |
AC |
213 ms |
14104 KiB |
| 01_random_14.txt |
AC |
241 ms |
14120 KiB |
| 01_random_15.txt |
AC |
234 ms |
14120 KiB |
| 02_handmade_01.txt |
AC |
99 ms |
9448 KiB |
| 02_handmade_02.txt |
AC |
177 ms |
13280 KiB |