Submission #636900

#TimeUsernameProblemLanguageResultExecution timeMemory
636900HossamHero7Subway (info1cup19_subway)C++14
100 / 100
9 ms808 KiB
#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 (stderr)

subway.cpp: In function 'void solve()':
subway.cpp:13:19: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   13 |         ll md = l + r >> 1;
      |                 ~~^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...