Submission #928623

# Submission time Handle Problem Language Result Execution time Memory
928623 2024-02-16T19:25:36 Z MilosMilutinovic A Plus B (IOI23_aplusb) C++17
0 / 100
1000 ms 348 KB
#include "aplusb.h"
#include<bits/stdc++.h>
 
#define pb push_back
#define fi first
#define se second
#define mp make_pair
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef long double ld;
 
template <typename T> bool chkmin(T &x,T y){return x>y?x=y,1:0;}
template <typename T> bool chkmax(T &x,T y){return x<y?x=y,1:0;}
 
ll readint(){
	ll x=0,f=1; char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}

vector<int> smallest_sums(int n,vector<int> a,vector<int> b){
	int l=0,r=(int)2e9,s=0;
	while(l<=r){
		int mid=(l+r)/2;
		int ptr=0;
		ll cnt=0;
		for(int i=n-1;i>=0;i--){
			while(ptr<n&&a[i]+b[ptr]<=mid) ptr++;
			cnt+=ptr;
		}
		if(cnt>=n) s=mid,r=mid-1; else l=mid+1;
	}
	vector<int> ret;
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			if(a[i]+b[j]<s) ret.pb(a[i]+b[j]);
			else break;
		}
	}
	while(ret.size()<n) ret.pb(s);
	sort(ret.begin(),ret.end());
	return ret;
}

Compilation message

aplusb.cpp: In function 'std::vector<int> smallest_sums(int, std::vector<int>, std::vector<int>)':
aplusb.cpp:46:18: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   46 |  while(ret.size()<n) ret.pb(s);
      |        ~~~~~~~~~~^~
# 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 1093 ms 348 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 1093 ms 348 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 1093 ms 348 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 1093 ms 348 KB Time limit exceeded
5 Halted 0 ms 0 KB -