답안 #841730

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
841730 2023-09-02T01:34:47 Z Muhammad_Aneeq A Plus B (IOI23_aplusb) C++17
100 / 100
41 ms 4900 KB
#include <vector>
#include <algorithm>
#include "aplusb.h"
using namespace std;
inline bool check(vector<int>a,vector<int>b,int o)
{
	int k=a.size();
	for (int i=0;i<a.size();i++)
    {
      for (int j=0;j<a.size();j++)
      {
        if (a[i]+b[j]<=o)
          k--;
      else
       break;
      	if (k==0)
      		return 1;
      }
    }	
    return 0;
}
vector<int> smallest_sums(int n,vector<int> a ,vector<int> b)
{
  long long st=-1,en=2e9+10;
  while (st+1<en)
  {
    int mid=(st+en)/2;
    if (check(a,b,mid))
      en=mid;
    else
      st=mid;  
  }
  vector<int>ans;
  int k=0;
  for (int i=0;i<n;i++)
    {
      for (int j=0;j<n;j++)
      {
        if (a[i]+b[j]<=en)
          ans.push_back(a[i]+b[j]);
      else
      	break;
      }
    }
    sort(ans.begin(), ans.end());
    ans.resize(n);
    return ans;
}

Compilation message

aplusb.cpp: In function 'bool check(std::vector<int>, std::vector<int>, int)':
aplusb.cpp:8:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    8 |  for (int i=0;i<a.size();i++)
      |               ~^~~~~~~~~
aplusb.cpp:10:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   10 |       for (int j=0;j<a.size();j++)
      |                    ~^~~~~~~~~
aplusb.cpp: In function 'std::vector<int> smallest_sums(int, std::vector<int>, std::vector<int>)':
aplusb.cpp:34:7: warning: unused variable 'k' [-Wunused-variable]
   34 |   int k=0;
      |       ^
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 424 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 424 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 1 ms 348 KB Output is correct
26 Correct 1 ms 348 KB Output is correct
27 Correct 2 ms 348 KB Output is correct
28 Correct 1 ms 348 KB Output is correct
29 Correct 0 ms 348 KB Output is correct
30 Correct 1 ms 348 KB Output is correct
31 Correct 1 ms 348 KB Output is correct
32 Correct 1 ms 348 KB Output is correct
33 Correct 1 ms 348 KB Output is correct
34 Correct 1 ms 348 KB Output is correct
35 Correct 1 ms 348 KB Output is correct
36 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 424 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 1 ms 348 KB Output is correct
26 Correct 1 ms 348 KB Output is correct
27 Correct 2 ms 348 KB Output is correct
28 Correct 1 ms 348 KB Output is correct
29 Correct 0 ms 348 KB Output is correct
30 Correct 1 ms 348 KB Output is correct
31 Correct 1 ms 348 KB Output is correct
32 Correct 1 ms 348 KB Output is correct
33 Correct 1 ms 348 KB Output is correct
34 Correct 1 ms 348 KB Output is correct
35 Correct 1 ms 348 KB Output is correct
36 Correct 1 ms 348 KB Output is correct
37 Correct 8 ms 1272 KB Output is correct
38 Correct 26 ms 3420 KB Output is correct
39 Correct 32 ms 3648 KB Output is correct
40 Correct 27 ms 3492 KB Output is correct
41 Correct 38 ms 4812 KB Output is correct
42 Correct 37 ms 4900 KB Output is correct
43 Correct 35 ms 4316 KB Output is correct
44 Correct 8 ms 1280 KB Output is correct
45 Correct 28 ms 3984 KB Output is correct
46 Correct 28 ms 3732 KB Output is correct
47 Correct 30 ms 3700 KB Output is correct
48 Correct 41 ms 4828 KB Output is correct
49 Correct 39 ms 4836 KB Output is correct
50 Correct 36 ms 4316 KB Output is correct
51 Correct 35 ms 4056 KB Output is correct
52 Correct 35 ms 4060 KB Output is correct
53 Correct 37 ms 4060 KB Output is correct