CODE FESTIVAL 2016 Final

Submission #992616

Source codeソースコード

#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <sstream>
#include <map>

typedef long long ll;
#define rep(i, b) for(int i = 0; i < b; i++)
#define repi(i, a, b) for(int i = a; i < b; i++)
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define MAX_V 1001
#define MAX_E 401
#define MOD 1000000007
#define EPS 1e-7
#define INF INT_MAX
#define PI  3.14159265358979323846264338327950288
inline ll toll(std::string s) { ll v; std::istringstream sin(s); sin >> v; return v; }
template<class T> inline std::string toString(T x) { std::ostringstream sout; sout << x; return sout.str(); }
using namespace std;
typedef pair<ll, ll> pll;

int main()
{
    ll N;
    cin >> N;
    
    if (N == 1 | N == 2)
    {
        cout << N << endl;
        return 0;
    }
    
    vector<ll> sum;
    vector<ll> sum_size;
    int count = 1;
    repi(i,2,100000)
    {
        if(i == 2)
        {
            sum.push_back(i);
            sum_size.push_back(count++);
            //11cout << i << endl;
        }
        else{
            //cout << i + sum[sum.size() - 1] << endl;
            sum_size.push_back(count++);
            sum.push_back(i + sum[sum.size() - 1]);
            if (sum[sum.size()-1] > 10000000)
            {
                break;
            }
        }
    }
    
    vector<ll> ans;
    rep(i,sum.size())
    {
        if(sum[i] >= N)
        {
            //cout << sum[i] << endl;
            rep(j,sum_size[i])
            {
                ans.push_back(j + 1);
            }
            rep(j,sum_size[i] - (sum[i] - N))
            {
                ans[ans.size() - 1 - j]++;
            }
            break;
        }
    }
    
    rep(i,ans.size())
    {
        cout << ans[i] << endl;
    }
    return 0;
}

Submission

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

Test case

Case name Status状態 Exec time実行時間 Memory usageメモリ使用量
01-01.txt AC 2 ms 256 KB
01-02.txt AC 2 ms 384 KB
01-03.txt AC 3 ms 384 KB
01-04.txt AC 3 ms 384 KB
01-05.txt AC 3 ms 384 KB
01-06.txt AC 3 ms 384 KB
01-07.txt AC 3 ms 384 KB
01-08.txt AC 3 ms 384 KB
01-09.txt AC 3 ms 384 KB
01-10.txt AC 3 ms 384 KB
02-01.txt AC 17 ms 512 KB
02-02.txt AC 21 ms 512 KB
02-03.txt AC 21 ms 512 KB
02-04.txt AC 21 ms 512 KB
02-05.txt AC 21 ms 512 KB
02-06.txt AC 12 ms 384 KB
02-07.txt AC 9 ms 384 KB
02-08.txt AC 20 ms 512 KB
sample-01.txt AC 2 ms 384 KB
sample-02.txt AC 3 ms 384 KB
sample-03.txt AC 2 ms 256 KB