Submission #1652919


Source Code Expand

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main(){
  int w,h;
  cin >> w >> h;
  
  vector<int> p(w+1), q(h+1);
  for(int i=0; i<w; i++){
    cin >> p[i];
  }
  for(int i=0; i<h; i++){
    cin >> q[i];
  }
  p[w] = q[h] = 1e9;

  sort(p.begin(), p.end());
  sort(q.begin(), q.end());
  
  long long int ans=0;
  int pidx=0, qidx=0;
  while(!(w==0 && h==0)){
    if(p[pidx]*(h+1) < q[qidx]*(w+1)){
      ans += p[pidx]*(h+1);
      w--;
      pidx++;
    }else{
      ans += q[qidx]*(w+1);
      h--;
      qidx++;
    }
  }

  cout << ans << endl;
  return 0;
}

Submission Info

Submission Time
Task C - Gr-idian MST
User syl659
Language C++14 (GCC 5.4.1)
Score 0
Code Size 642 Byte
Status RE
Exec Time 188 ms
Memory 1024 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 500
Status
AC × 2
AC × 7
RE × 23
Set Name Test Cases
Sample s1.txt, s2.txt
All 01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt, 11.txt, 12.txt, 13.txt, 14.txt, 15.txt, 16.txt, 17.txt, 18.txt, 19.txt, 20.txt, 21.txt, 22.txt, 23.txt, 24.txt, 25.txt, 26.txt, 27.txt, 28.txt, s1.txt, s2.txt
Case Name Status Exec Time Memory
01.txt RE 187 ms 1024 KB
02.txt RE 186 ms 1024 KB
03.txt RE 186 ms 1024 KB
04.txt RE 186 ms 1024 KB
05.txt RE 185 ms 1024 KB
06.txt RE 186 ms 1024 KB
07.txt RE 186 ms 1024 KB
08.txt RE 187 ms 1024 KB
09.txt RE 185 ms 1024 KB
10.txt RE 186 ms 1024 KB
11.txt RE 181 ms 1024 KB
12.txt RE 181 ms 1024 KB
13.txt RE 175 ms 1024 KB
14.txt RE 187 ms 1024 KB
15.txt RE 188 ms 1024 KB
16.txt RE 142 ms 640 KB
17.txt RE 142 ms 640 KB
18.txt RE 148 ms 640 KB
19.txt RE 142 ms 640 KB
20.txt AC 35 ms 1024 KB
21.txt RE 160 ms 1024 KB
22.txt RE 161 ms 1024 KB
23.txt RE 159 ms 1024 KB
24.txt RE 182 ms 1024 KB
25.txt AC 1 ms 256 KB
26.txt AC 1 ms 256 KB
27.txt AC 1 ms 256 KB
28.txt AC 1 ms 256 KB
s1.txt AC 1 ms 256 KB
s2.txt AC 1 ms 256 KB