답안 #667226

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
667226 2022-11-30T20:49:03 Z divad Subway (info1cup19_subway) C++14
0 / 100
1 ms 212 KB
#include <iostream>
#define int long long
using namespace std;
int k;

int gauss(int n){
    return n*(n+1)/2;
}

signed main()
{
    cin >> k;
    int ans = 0, st = 1, dr = 45000;
    /// 1 1 1 1 1 0 0 0 0 0 0
    ///         ^
    while(st <= dr){
        int mid = (st+dr)/2;
        if(gauss(mid) <= k){
            ans = mid;
            st = mid+1;
        }else{
            dr = mid-1;
        }
    }
    int rest = k-gauss(ans);
    int cnt = 1+ans+(rest > 0);
    cout << cnt << "\n";
    cout << "0 -1\n";
    for(int i = 1; i <= ans; i++){
        cout << i << " " << i-1 << "\n";
    }
    if(rest){
        cout << cnt << " " << rest-1 << "\n";
    }
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Incorrect 1 ms 212 KB Integer parameter [name=X] equals to 11, violates the range [0, 10]
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Incorrect 1 ms 212 KB Integer parameter [name=X] equals to 11, violates the range [0, 10]
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Incorrect 1 ms 212 KB Integer parameter [name=X] equals to 11, violates the range [0, 10]
4 Halted 0 ms 0 KB -