제출 #64063

#제출 시각아이디문제언어결과실행 시간메모리
64063Just_Solve_The_ProblemZalmoxis (BOI18_zalmoxis)C++17
10 / 100
433 ms10596 KiB
#include <bits/stdc++.h>

using namespace std;

#define ll long long

const int N = (int)1e6 + 7;
const int inf = (int)1e9 + 7;

int n, k;
ll a[N];
map < ll, int > cnt;

main() {
  scanf("%d %d", &n, &k);
  ll mn = (ll)1e18;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    mn = min(mn, a[i]);
    cnt[a[i]]++;
  }
  ll cur = -1;
  while (1) {
    if (cnt[mn] & 1) {
      cur = mn;
      break;
    }
    cnt[mn + 1] += cnt[mn] / 2;
    cnt[mn] = 0;
    mn++;
  }
  int in;
  for (int i = 1; i <= n; i++) {
    if (a[i] <= cur) {
      in = i;
    }
  }
  for (int i = 1; i <= n; i++) {
    if (i == in)
      cout << cur << ' ';
    cout << a[i] << ' ';
  }
}

컴파일 시 표준 에러 (stderr) 메시지

zalmoxis.cpp:14:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main() {
      ^
zalmoxis.cpp: In function 'int main()':
zalmoxis.cpp:15:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d %d", &n, &k);
   ~~~~~^~~~~~~~~~~~~~~~~
zalmoxis.cpp:39:5: warning: 'in' may be used uninitialized in this function [-Wmaybe-uninitialized]
     if (i == in)
     ^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...