Submission #1051612

#TimeUsernameProblemLanguageResultExecution timeMemory
1051612becaidoA Plus B (IOI23_aplusb)C++17
100 / 100
31 ms5840 KiB
#pragma GCC optimize("O3,unroll-loops") #pragma GCC target("avx,popcnt,sse4,abm") #include <bits/stdc++.h> using namespace std; #ifndef WAIMAI #include "aplusb.h" #else #include "grader.cpp" #endif #ifdef WAIMAI #define debug(HEHE...) cout << "[" << #HEHE << "] : ", dout(HEHE) void dout() {cout << '\n';} template<typename T, typename...U> void dout(T t, U...u) {cout << t << (sizeof...(u) ? ", " : ""), dout(u...);} #else #define debug(...) 7122 #endif #define ll long long #define Waimai ios::sync_with_stdio(false), cin.tie(0) #define FOR(x,a,b) for (int x = a, I = b; x <= I; x++) #define pb emplace_back #define F first #define S second vector<int> smallest_sums(int N, vector<int> A, vector<int> B) { priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> pq; vector<int> ans, ptr(N, 0); FOR (i, 0, N - 1) pq.emplace(A[i] + B[0], i); while (ans.size() < N) { auto [sum, i] = pq.top(); pq.pop(); ans.pb(sum); if (++ptr[i] < N) pq.emplace(A[i] + B[ptr[i]], i); } return ans; } /* in1 2 0 2 1 4 out1 1 3 in2 3 0 2 2 3 5 6 out2 3 5 5 */

Compilation message (stderr)

aplusb.cpp: In function 'std::vector<int> smallest_sums(int, std::vector<int>, std::vector<int>)':
aplusb.cpp:32:23: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   32 |     while (ans.size() < N) {
      |            ~~~~~~~~~~~^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...