Submission #138838

#TimeUsernameProblemLanguageResultExecution timeMemory
138838Talant저울 (IOI15_scales)C++17
55.56 / 100
2 ms424 KiB
#include "scales.h"
//#include "grader.cpp"

#include <bits/stdc++.h>

#define sc second
#define fr first
#define mk make_pair
#define pb push_back

using namespace std;

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


int t;
int a[7];
int f = 0;
int w[7];
int o,cur;
void init(int T) {
      t = T;
}

void orderCoins() {
      f = 0;
      o = cur = 0;
      for (int i = 0; i < 6; i ++)
            a[i] = 0;

      a[2] = getHeaviest(1,2,3);
      a[1] = getMedian(1,2,3);
      a[0] = 6 - (a[2] + a[1]);

      a[5] = getHeaviest(4,5,6);
      a[4] = getMedian(4,5,6);
      a[3] = 15 - a[5] - a[4];

      int mx = getHeaviest(a[2],a[3],a[5]);

      if (mx != a[2]) {
            swap(a[0],a[3]);
            swap(a[1],a[4]);
            swap(a[2],a[5]);
      }

      o = getNextLightest(a[0],a[1],a[2],a[3]);
      cur = a[3];
      for (int i = 2; i >= 0; i --) {
            a[i + 1] = a[i];
            if (a[i] == o) {
                  a[i] = cur;
                  break;
            }
      }

      o = getNextLightest(a[1],a[2],a[3],a[4]);
      cur = a[4];
      for (int i = 3; i >= 0; i --) {
            a[i + 1] = a[i];
            if (a[i] == o) {
                  a[i] = cur;
                  break;
            }
      }
      o = getNextLightest(a[2],a[3],a[4],a[5]);
      cur = a[5];
      for (int i = 4; i >= 0; i --) {
            a[i + 1] = a[i];
            if (a[i] == o) {
                  a[i] = cur;
                  break;
            }
      }
      answer(a);
}
#Verdict Execution timeMemoryGrader output
Fetching results...