Submission #45841417
Source Code Expand
#include<bits/stdc++.h>
//#include<atcoder/all>
using namespace std;
//using namespace atcoder;
typedef long long ll;
#define rep(i,n) for(ll i=0;i<n;++i)
#define rrep(i,n) for(ll i=n-1;i>=0;--i)
#define FOR(i,s,e) for(ll i=s;i<=e;++i)
#define FFOR(i,s,e) for(ll i=s;i>=e;--i)
#define yesno(flg) if(flg){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}
#define ALL(a) (a).begin(),(a).end()
#define mp make_pair
#define pb push_back
#define vl vector<ll>
#define vs vector<string>
#define so(a) sort(a.begin(),a.end())
#define fi first
#define se second
#define print(a) cout<<a<<endl
#define ssize(a) (ll)(a.size())
#define MAX_N 1002
#define i197 1000000007
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF=1000000000000000001;
struct edge
{
int to, cost;
};
struct pos{
// 1 変数を入れる;
ll t;
ll x,y;
set<ll> st;
};
int dx[4] = { 1, 0, -1, 0};
int dy[4] = { 0, 1, 0, -1};
int dd[5] = { 0, 1, 0, -1, 0};
typedef pair<ll, ll> P2;
typedef pair<pair<ll,ll>,ll> P3;
typedef pair<string,ll> Ps;
typedef pair<pair<ll,ll>,pair<ll,ll> > P4;
int main(){
ios::sync_with_stdio(0);
cin.tie(0);
ll n,m,p;
cin>>n>>m>>p;
vl a(n),b(m);
rep(i,n)cin>>a[i];
rep(i,m)cin>>b[i];
sort(a.begin(),a.end(),greater<ll>());
so(b);
ll z=-1,t=0;
ll ans=0;
rep(i,n){
while(z+1<m){
if(a[i]+b[z+1]<=p){
t+=b[z+1];
z++;
}else break;
}
ans+=a[i]*(z+1)+t;
ans+=p*(m-z-1);
}
print(ans);
return 0;
}
Submission Info
| Submission Time |
|
| Task |
D - Set Menu |
| User |
akarinkof |
| Language |
C++ 20 (gcc 12.2) |
| Score |
400 |
| Code Size |
1673 Byte |
| Status |
AC |
| Exec Time |
47 ms |
| Memory |
6316 KiB |
Judge Result
| Set Name |
Sample |
All |
| Score / Max Score |
0 / 0 |
400 / 400 |
| Status |
|
|
| Set Name |
Test Cases |
| Sample |
00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt |
| All |
00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 01_random_00.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, 01_random_16.txt, 01_random_17.txt, 01_random_18.txt, 01_random_19.txt, 01_random_20.txt, 01_random_21.txt, 01_random_22.txt, 01_random_23.txt, 01_random_24.txt, 02_handmade_00.txt, 02_handmade_01.txt |
| Case Name |
Status |
Exec Time |
Memory |
| 00_sample_00.txt |
AC |
1 ms |
3416 KiB |
| 00_sample_01.txt |
AC |
1 ms |
3608 KiB |
| 00_sample_02.txt |
AC |
1 ms |
3436 KiB |
| 01_random_00.txt |
AC |
1 ms |
3320 KiB |
| 01_random_01.txt |
AC |
24 ms |
4572 KiB |
| 01_random_02.txt |
AC |
23 ms |
4620 KiB |
| 01_random_03.txt |
AC |
28 ms |
4900 KiB |
| 01_random_04.txt |
AC |
46 ms |
6312 KiB |
| 01_random_05.txt |
AC |
17 ms |
4116 KiB |
| 01_random_06.txt |
AC |
8 ms |
3788 KiB |
| 01_random_07.txt |
AC |
15 ms |
4064 KiB |
| 01_random_08.txt |
AC |
28 ms |
4904 KiB |
| 01_random_09.txt |
AC |
23 ms |
4580 KiB |
| 01_random_10.txt |
AC |
46 ms |
6312 KiB |
| 01_random_11.txt |
AC |
10 ms |
3792 KiB |
| 01_random_12.txt |
AC |
46 ms |
6168 KiB |
| 01_random_13.txt |
AC |
47 ms |
6296 KiB |
| 01_random_14.txt |
AC |
21 ms |
4320 KiB |
| 01_random_15.txt |
AC |
33 ms |
6156 KiB |
| 01_random_16.txt |
AC |
33 ms |
6316 KiB |
| 01_random_17.txt |
AC |
33 ms |
6188 KiB |
| 01_random_18.txt |
AC |
33 ms |
6080 KiB |
| 01_random_19.txt |
AC |
35 ms |
6080 KiB |
| 01_random_20.txt |
AC |
26 ms |
6160 KiB |
| 01_random_21.txt |
AC |
26 ms |
6156 KiB |
| 01_random_22.txt |
AC |
26 ms |
6244 KiB |
| 01_random_23.txt |
AC |
26 ms |
6204 KiB |
| 01_random_24.txt |
AC |
26 ms |
6308 KiB |
| 02_handmade_00.txt |
AC |
1 ms |
3396 KiB |
| 02_handmade_01.txt |
AC |
25 ms |
6168 KiB |