Submission #846003

# Submission time Handle Problem Language Result Execution time Memory
846003 2023-09-07T05:09:34 Z Mohamed_Kachef06 A Plus B (IOI23_aplusb) C++17
10 / 100
1 ms 348 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
vector<int> smallest_sums(int n , vector<int> a, vector<int> b){
    ll l = 0 , r = 2e9 , md;
    while(l<=r){
        md = (l+r)/2;
        ll cnt =0 ;
        for (int i = 0 ; i<n ; i++){
            if (md >= a[i]) cnt+=lower_bound(b.begin() , b.end() , md - a[i]) - b.begin();
        }
        if (cnt < n) l = md+1;
        else r = md-1;
    }
    ll ans = l-1;
    vector<int> c;
    for (int i = 0 ; i<n ; i++){
        for (int j = 0 ; j<n ; j++){
            if (a[i] + b[j] < ans) c.pb(a[i] + b[j]);
            else break;

        }
    }
    while(c.size() < n) c.pb(ans);
    return c;
}

// signed main(){
//     int n ;     cin >> n;

//     vector<int> a(n) , b(n);
//     for (int i =0 ; i <n ; i++) cin >> a[i];
//     for (int i = 0 ; i<n ; i++) cin >> b[i];
//     vector<int> c = smallest_sums(n , a , b);
//     for (auto i : c) cout << i << ' ';
// }

Compilation message

aplusb.cpp: In function 'std::vector<int> smallest_sums(int, std::vector<int>, std::vector<int>)':
aplusb.cpp:25:20: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   25 |     while(c.size() < n) c.pb(ans);
      |           ~~~~~~~~~^~~
# 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 Correct 0 ms 344 KB Output is correct
# 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 Correct 0 ms 344 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Incorrect 0 ms 344 KB 1st lines differ - on the 4th token, expected: '30', found: '64'
8 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 Correct 0 ms 344 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Incorrect 0 ms 344 KB 1st lines differ - on the 4th token, expected: '30', found: '64'
8 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 Correct 0 ms 344 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Incorrect 0 ms 344 KB 1st lines differ - on the 4th token, expected: '30', found: '64'
8 Halted 0 ms 0 KB -