Submission #636900

# Submission time Handle Problem Language Result Execution time Memory
636900 2022-08-30T11:55:43 Z HossamHero7 Subway (info1cup19_subway) C++14
100 / 100
9 ms 808 KB
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
#define endl '\n'
void solve(){
    ll k;
    cin>>k;
    ll ans = 0;
    int l=1;
    int r=1e5;
    while(l<=r){
        ll md = l + r >> 1;
        if(md*(md-1)/2 <= k){
            ans = md;
            l = md+1;
        }
        else r = md-1;
    }
    ll x = k-ans*(ans-1)/2;
    x --;
    cout<<ans+(x>=0)<<endl;
    cout<<0<<" "<<-1<<endl;
    for(int i=0;i<ans-1;i++){
        cout<<i+1<<" "<<i<<endl;
    }
    if(x>=0)cout<<ans<<' '<<x<<endl;
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);      cout.tie(0);
    int t=1;
    // cin>>t;
    while(t--){
        solve();
    }
    return 0;
}

Compilation message

subway.cpp: In function 'void solve()':
subway.cpp:13:19: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   13 |         ll md = l + r >> 1;
      |                 ~~^~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 324 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 224 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 324 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 224 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 724 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 9 ms 808 KB Output is correct
19 Correct 6 ms 596 KB Output is correct
20 Correct 6 ms 576 KB Output is correct