# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1208694 | horiaboeriu | Subway (info1cup19_subway) | C++20 | 4 ms | 840 KiB |
#include <bits/stdc++.h>
using namespace std;
int main()
{
//cel mai bine este ca fiecare x sa fie fiul lui x - 1, asa vor fi un nr maxim de drumuri
int k, s, n, i;
scanf("%d", &k);
if (k == 0) {
printf("1\n0 -1\n");
} else {
n = 1;
while (n * (n + 1) / 2 < k) {
n++;
}
s = n * (n - 1) / 2;//ultima suma < k
n++;
printf("%d\n0 -1\n", n);
for (i = 1; i < n - 1; i++) {
printf("%d %d\n", i, i - 1);
}
printf("%d %d\n", i, k - s - 1);
}
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |