CODE FESTIVAL 2016 Final

Submission #1152169

Source codeソースコード

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

const int N = 5000;

int n, len;
int g[N], f[N][N], pre[N][N];
int vis[N];

void init() {
  g[0] = 0;
  for (int i = 1;; i++) {
    g[i] = g[i - 1] + i;
    if (g[i - 1] + i > (int)1e7) {
      len = i;
      break;
    }
  }
}

int main() {
  init();
  cin >> n;
  int v = lower_bound(g + 1, g + 1 + len, n) - g;
  int val = g[v] - n;
  f[0][0] = 1;
  for (int i = 1; i <= v; i++) {
    for (int j = 0; j <= val; j++) {
      if (j - i >= 0 && f[i - 1][j - i] == 1) f[i][j] = 1, pre[i][j] = j - i;
      if (f[i - 1][j] == 1) f[i][j] = 1, pre[i][j] = j;
    }
  }
  int pt = v;
  while (pt >= 1) {
    int key = pre[pt][val];
    vis[val - key] = 1;
    pt--, val = key;
  }
  for (int i = 1; i <= v; i++) {
    if (vis[i]) continue;
    printf("%d\n", i);
  }
  return 0;
}


Submission

Task問題 B - Exactly N points
User nameユーザ名 kakapo95
Created time投稿日時
Language言語 C++14 (GCC 5.4.1)
Status状態 AC
Score得点 300
Source lengthソースコード長 871 Byte
File nameファイル名
Exec time実行時間 72 ms
Memory usageメモリ使用量 177664 KB

Test case

Set

Set name Score得点 / Max score Cases
sample - sample-01.txt,sample-02.txt,sample-03.txt
dataset1 200 / 200 sample-01.txt,sample-02.txt,sample-03.txt,01-01.txt,01-02.txt,01-03.txt,01-04.txt,01-05.txt,01-06.txt,01-07.txt,01-08.txt,01-09.txt,01-10.txt
dataset2 100 / 100 sample-01.txt,sample-02.txt,sample-03.txt,01-01.txt,01-02.txt,01-03.txt,01-04.txt,01-05.txt,01-06.txt,01-07.txt,01-08.txt,01-09.txt,01-10.txt,02-01.txt,02-02.txt,02-03.txt,02-04.txt,02-05.txt,02-06.txt,02-07.txt,02-08.txt,sample-01.txt,sample-02.txt,sample-03.txt

Test case

Case name Status状態 Exec time実行時間 Memory usageメモリ使用量
01-01.txt AC 2 ms 2304 KB
01-02.txt AC 2 ms 2304 KB
01-03.txt AC 2 ms 2304 KB
01-04.txt AC 2 ms 2304 KB
01-05.txt AC 2 ms 2432 KB
01-06.txt AC 2 ms 4480 KB
01-07.txt AC 2 ms 4480 KB
01-08.txt AC 2 ms 4480 KB
01-09.txt AC 2 ms 4608 KB
01-10.txt AC 2 ms 4608 KB
02-01.txt AC 38 ms 176768 KB
02-02.txt AC 38 ms 176768 KB
02-03.txt AC 72 ms 177664 KB
02-04.txt AC 71 ms 177536 KB
02-05.txt AC 49 ms 177280 KB
02-06.txt AC 25 ms 95232 KB
02-07.txt AC 18 ms 66560 KB
02-08.txt AC 55 ms 171264 KB
sample-01.txt AC 2 ms 2304 KB
sample-02.txt AC 2 ms 2304 KB
sample-03.txt AC 2 ms 2304 KB