ABOUT ME

-

Today
-
Yesterday
-
Total
-
  • 백준 15552 - 빠른 A+B
    백준 algorithm 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;
    }

    '백준 algorithm' 카테고리의 다른 글

    백준 2231 - 분해합  (0) 2019.09.10
    백준 2292 - 벌집  (0) 2019.09.08
    백준 2562 - 최댓값  (0) 2019.09.06
    백준 2577 - 숫자의 개수  (0) 2019.09.06
    백준 3052 - 나머지  (0) 2019.09.04

    댓글

Designed by Who.