Submission #846002

# Submission time Handle Problem Language Result Execution time Memory
846002 2023-09-07T05:07:05 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;
            if (c.size() == n) break;

        }
        if (c.size() == n) break;
    }
    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:22:26: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   22 |             if (c.size() == n) break;
      |                 ~~~~~~~~~^~~~
aplusb.cpp:25:22: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   25 |         if (c.size() == n) break;
      |             ~~~~~~~~~^~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Incorrect 0 ms 348 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 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Incorrect 0 ms 348 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 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Incorrect 0 ms 348 KB 1st lines differ - on the 4th token, expected: '30', found: '64'
8 Halted 0 ms 0 KB -