Submission #1315844

#TimeUsernameProblemLanguageResultExecution timeMemory
1315844penguin133Subway (info1cup19_subway)C++20
100 / 100
4 ms1592 KiB
// Source: https://usaco.guide/general/io

#include <bits/stdc++.h>
using namespace std;

int main() {
	int n; cin >> n;
    int ans[200005], tot = 0, b = 0;
    if (!n) {
      cout << 1 << '\n' << "0 -1";
      return 0;
    }
    ans[0] = -1;
    for (int i = 1; i <= n; i++) {
        if (tot + i >= n) {
            int req = n - tot;
            ans[i] = req - 1;
            b = i + 1;
            break;
        }
        else {
            tot += i;
            ans[i] = i - 1;
        }
    }
    cout << b << '\n';
    for (int i = 0; i < b; i++) cout << i << ' ' << ans[i] << '\n';
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...