백준 algorithm
백준 15552 - 빠른 A+B
cosmohoo
2019. 9. 7. 13:27
반응형

실행속도를 올리기 위해서
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
\n
를 사용하여 실행속도를 올릴 수 있다.
대신 ios::sync_with_stdio(false); 같은 경우는 싱글스레드에서만 사용하는 것이 안전하다고 한다.
시간초과가 난다면 C 표준입출력 함수들을 사용하는 것이 추천된다.
#include <iostream>
#include <vector>
using namespace std;
int main()
{
ios::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int num;
int A, B = 0;
cin >> num;
vector<int> arr;
for (int i = 0; i < num; i++)
{
cin >> A >> B;
arr.push_back(A + B);
}
for (auto j = arr.begin(); j <arr.end(); j++)
{
cout << *j << '\n';
}
return 0;
}반응형