답안 #667228

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
667228 2022-11-30T20:53:43 Z divad Subway (info1cup19_subway) C++14
100 / 100
7 ms 796 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);
    cout << ans+1+(rest > 0) << "\n";
    cout << "0 -1\n";
    for(int i = 1; i <= ans; i++){
        cout << i << " " << i-1 << "\n";
    }
    if(rest){
        cout << ans+1 << " " << rest-1 << "\n";
    }
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 2 ms 340 KB Output is correct
12 Correct 2 ms 340 KB Output is correct
13 Correct 3 ms 340 KB Output is correct
14 Correct 2 ms 340 KB Output is correct
15 Correct 2 ms 340 KB Output is correct
16 Correct 7 ms 796 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 7 ms 724 KB Output is correct
19 Correct 5 ms 572 KB Output is correct
20 Correct 5 ms 596 KB Output is correct