답안 #721277

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
721277 2023-04-10T15:35:03 Z vjudge1 Uzastopni (COCI17_uzastopni) C++17
64 / 80
1000 ms 320 KB
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ld long double
#define ll long long
#define S second
#define F first

using namespace __gnu_pbds;
using namespace std;

typedef tree<long long, null_type, less_equal<long long>,
    rb_tree_tag, tree_order_statistics_node_update> Tree;

const ll INF = 9223372036854775807LL;
const ll inf = 2147483647;
const ll MAXN = 200010;
const ll MOD = 1e9 + 7;
const ld PI = acos(-1);
const ll NROOT = 320; 

ll binpow(ll a, ll b) {
  ll res = 1;
  for (;b; b /= 2, a *= a, a %= MOD)
    if (b & 1) res *= a, res %= MOD;
  return res % MOD;
}

ll gcd(ll a, ll b) {return b ? gcd(b, a % b) : a;}
ll lcm(ll a, ll b) {return a * b / gcd(a, b);}
ll invmod(ll a) {return binpow(a, MOD - 2);}

int bs(ll x, vector<ll> &v) {
  int l = 0, r = v.size() - 1;

  while (l <= r) {
    int m = (l + r) / 2;
    if (v[m] == x) return m;
    if (v[m] < x) l = m + 1;
    if (v[m] > x) r = m - 1;
  }
  return -1;
}

int32_t main () {
  ios_base::sync_with_stdio(false); 
  cin.tie(nullptr);

  ll n; cin >> n;

  
  ll sum = 3;
  ll i = 1, j = 2;

  while (i < j) {
    if (sum > n) {
      sum -= i;
      i ++;
    } else if (sum < n) {
      j ++;
      sum += j;
    } else {
      cout << i << " " << j << "\n";
      j ++;
      sum += j;
    }
  }

  return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 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 5 ms 212 KB Output is correct
7 Correct 13 ms 320 KB Output is correct
8 Correct 138 ms 296 KB Output is correct
9 Execution timed out 1066 ms 300 KB Time limit exceeded
10 Execution timed out 1074 ms 212 KB Time limit exceeded