Submission #953999

# Submission time Handle Problem Language Result Execution time Memory
953999 2024-03-27T05:10:11 Z pcc A Plus B (IOI23_aplusb) C++17
0 / 100
1000 ms 348 KB
#include "aplusb.h"
#include <bits/stdc++.h>
using namespace std;

long long f(int lim,vector<int> &A,vector<int>& B){
	long long re = 0;
	for(int i = 0;i<A.size();i++){
		auto pos = upper_bound(B.begin(),B.end(),lim-A[i])-B.begin();
		re += pos;
	}
	return re;
}


std::vector<int> smallest_sums(int N, std::vector<int> A, std::vector<int> B) {
	int l = 0,r = 2e9;
	while(l != r){
		int mid = (l+r)>>1;
		if(f(mid,A,B)>=N)r = mid;
		else l = mid+1;
	}
	vector<int> re;
	for(int i = 0;i<A.size();i++){
		for(int j = 0;j<B.size()&&A[i]+B[j]<l;j++)re.push_back(A[i]+B[j]);
	}
	while(re.size()<N)re.push_back(l);
	sort(re.begin(),re.end());
	return re;
}

Compilation message

aplusb.cpp: In function 'long long int f(int, std::vector<int>&, std::vector<int>&)':
aplusb.cpp:7:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    7 |  for(int i = 0;i<A.size();i++){
      |                ~^~~~~~~~~
aplusb.cpp: In function 'std::vector<int> smallest_sums(int, std::vector<int>, std::vector<int>)':
aplusb.cpp:23:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   23 |  for(int i = 0;i<A.size();i++){
      |                ~^~~~~~~~~
aplusb.cpp:24:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   24 |   for(int j = 0;j<B.size()&&A[i]+B[j]<l;j++)re.push_back(A[i]+B[j]);
      |                 ~^~~~~~~~~
aplusb.cpp:26:17: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   26 |  while(re.size()<N)re.push_back(l);
      |        ~~~~~~~~~^~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Execution timed out 1083 ms 344 KB Time limit exceeded
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Execution timed out 1083 ms 344 KB Time limit exceeded
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Execution timed out 1083 ms 344 KB Time limit exceeded
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Execution timed out 1083 ms 344 KB Time limit exceeded
5 Halted 0 ms 0 KB -