답안 #979665

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
979665 2024-05-11T09:37:02 Z canadavid1 A Plus B (IOI23_aplusb) C++17
10 / 100
0 ms 348 KB
#include "aplusb.h"
#include <set>
#include <utility>
std::vector<int> smallest_sums(int N, std::vector<int> A, std::vector<int> B) {
  	auto cmp = [&](auto a,auto b){return A[a.first]+B[a.second]<A[b.first]+B[b.second];};
	std::set<std::pair<int,int>,decltype(cmp)> q(cmp);
  	std::vector<int> out;
  	q.emplace(0,0);
  	while(out.size()<N)
    {
      auto[a,b] = *q.begin();
      out.push_back(A[a]+B[b]);
      q.erase(q.begin());
      if(a+1<A.size()) q.emplace(a+1,b);
      if(b+1<B.size()) q.emplace(a,b+1);
    }
  	return out;
}

Compilation message

aplusb.cpp: In function 'std::vector<int> smallest_sums(int, std::vector<int>, std::vector<int>)':
aplusb.cpp:9:20: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
    9 |    while(out.size()<N)
      |          ~~~~~~~~~~^~
aplusb.cpp:14:13: warning: comparison of integer expressions of different signedness: 'std::tuple_element<0, std::pair<int, int> >::type' {aka 'int'} and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   14 |       if(a+1<A.size()) q.emplace(a+1,b);
      |          ~~~^~~~~~~~~
aplusb.cpp:15:13: warning: comparison of integer expressions of different signedness: 'std::tuple_element<1, std::pair<int, int> >::type' {aka 'int'} and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   15 |       if(b+1<B.size()) q.emplace(a,b+1);
      |          ~~~^~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 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 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 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 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Incorrect 0 ms 348 KB 1st lines differ - on the 17th token, expected: '74', found: '140'
9 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 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 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Incorrect 0 ms 348 KB 1st lines differ - on the 17th token, expected: '74', found: '140'
9 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 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 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Incorrect 0 ms 348 KB 1st lines differ - on the 17th token, expected: '74', found: '140'
9 Halted 0 ms 0 KB -