CODE FESTIVAL 2016 Final

Submission #1152161

Source codeソースコード

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

const int N = 4500;

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++) {
    if (g[i - 1] + i > (int)1e7) {
      len = i - 1;
      break;
    }
    g[i] = g[i - 1] + i;
  }
}

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 <= n; 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 = n;
  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状態 RE
Score得点 200
Source lengthソースコード長 872 Byte
File nameファイル名
Exec time実行時間 ms
Memory usageメモリ使用量 -

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 0 / 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 4608 KB
01-05.txt AC 3 ms 6912 KB
01-06.txt AC 5 ms 21248 KB
01-07.txt AC 9 ms 37632 KB
01-08.txt AC 9 ms 37632 KB
01-09.txt AC 9 ms 37632 KB
01-10.txt AC 9 ms 37632 KB
02-01.txt RE
02-02.txt RE
02-03.txt RE
02-04.txt RE
02-05.txt RE
02-06.txt RE
02-07.txt RE
02-08.txt RE
sample-01.txt AC 2 ms 2304 KB
sample-02.txt AC 2 ms 2304 KB
sample-03.txt AC 2 ms 2304 KB