Submission #994166


Source Code Expand

Copy
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstring>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <limits>
using namespace std;
#define ll long long
#define ld long double
#define pii pair<int,int>
#define x first
#define y second
#define sf scanf
#define pf printf
#define vec vector
#define pb push_back
#define mp make_pair
#define sz(a) int(a.size())
#define all(a) a.begin(),a.end()
#define clr(a,b) memset(a,b,sizeof(a))
#define bin_cnt(x) __builtin_popcount(x)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define rrep(i,b,a) for(int i=b;i>=a;i--)
#define srep(sub,s) for(int sub=s&(s-1);sub;sub=(sub-1)&s)
#define irep(i,a) for(__typeof(a.begin()) i=a.begin();i!=a.end();i++)
#define irrep(i,a) for(__typeof(a.rbegin()) i=a.rbegin();i!=a.rend();i++)
#define inf numeric_limits<int>::max()
#define finf numeric_limits<double>::infinity()
#define eps 1e-8
#pragma GCC optimize ("O3")
#define o3 __attribute__((optimize("O3")))
#pragma comment(linker, "/STACK:32505856")

template<class T> inline T sqr(T a) {return a*a;}
template<class T> inline int gmin(T&a,T b) {if(a>b){a=b;return 1;}return 0;}
template<class T> inline int gmax(T&a,T b) {if(a<b){a=b;return 1;}return 0;}
inline int dcmp(const double &a) {return a>eps?1:(a<-eps?-1:0);}
struct Initializer{Initializer(){ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);}}initializer;

#define N 1000100
#define MAXN 1000010
vec<int> p;
vec<int> factors;
int np[MAXN] = {1, 1};

void get_primes() {
    for (int i = 2; i < MAXN; i++)
        if (!np[i]) {
            p.pb(i);
            for (int j = i + i; j < MAXN; j += i) {
                np[j] = 1;
            }
        }
}

void decompose(int n) {
    factors.clear();
    rep(i,0,sz(p) - 1) {
        while (n % p[i] == 0) {
            factors.pb(p[i]);
            n /= p[i];
            if (n == 1) return;
        }
    }
}


#define maxll 0x7fffffffffffffffll
ll n, ta;
ll f[N];
ll ans = maxll;

int main() {
//    get_primes();
    cin >> n >> ta;
    rep(i,2,n) f[i] = maxll;
    rep(i,1,n) {
        ll k = 2;
        for (ll j = i + i; j <= n; j += i, k ++) {
            ll tmp = f[i] + ta + k;
            if (f[j] > tmp) f[j] = tmp;
        }

        ll t = n / i;
        if (n % i) t++;
        t += f[i];
        if (ans > t) ans = t;
    }
    cout << ans << endl;
    return 0;
}

Submission Info

Submission Time
Task E - Cookies
User alpc104
Language C++14 (GCC 5.4.1)
Score 500
Code Size 2580 Byte
Status
Exec Time 119 ms
Memory 8064 KB

Judge Result

Set Name Score / Max Score Test Cases
sample 0 / 0 sample-01.txt, sample-02.txt, sample-03.txt
dataset1 500 / 500 sample-01.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, 01-11.txt, 01-12.txt, 01-13.txt, 01-14.txt, 01-15.txt, 01-16.txt, 01-17.txt, 01-18.txt, 01-19.txt, 01-20.txt, 01-21.txt, 01-22.txt, 01-23.txt, 01-24.txt, 01-25.txt, 01-26.txt
dataset2 0 / 500 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, 01-11.txt, 01-12.txt, 01-13.txt, 01-14.txt, 01-15.txt, 01-16.txt, 01-17.txt, 01-18.txt, 01-19.txt, 01-20.txt, 01-21.txt, 01-22.txt, 01-23.txt, 01-24.txt, 01-25.txt, 01-26.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, 02-09.txt, 02-10.txt, 02-11.txt, 02-12.txt, 02-13.txt, 02-14.txt, 02-15.txt, 02-16.txt, 02-17.txt, 02-18.txt, 02-19.txt, 02-20.txt, 02-21.txt, 02-22.txt, 02-23.txt, 02-24.txt, 02-25.txt, 02-26.txt, 02-27.txt, 02-28.txt, 02-29.txt, 02-30.txt, 02-31.txt, 02-32.txt, 02-33.txt, 02-34.txt, 02-35.txt, 02-36.txt, 02-37.txt, 02-38.txt, 02-39.txt, 02-40.txt
Case Name Status Exec Time Memory
01-01.txt 67 ms 8064 KB
01-02.txt 66 ms 8064 KB
01-03.txt 66 ms 8064 KB
01-04.txt 66 ms 8064 KB
01-05.txt 66 ms 8064 KB
01-06.txt 66 ms 8064 KB
01-07.txt 66 ms 8064 KB
01-08.txt 66 ms 8064 KB
01-09.txt 66 ms 8064 KB
01-10.txt 65 ms 8064 KB
01-11.txt 65 ms 8064 KB
01-12.txt 60 ms 8064 KB
01-13.txt 60 ms 8064 KB
01-14.txt 5 ms 768 KB
01-15.txt 32 ms 4352 KB
01-16.txt 32 ms 4352 KB
01-17.txt 65 ms 7936 KB
01-18.txt 3 ms 256 KB
01-19.txt 3 ms 256 KB
01-20.txt 3 ms 256 KB
01-21.txt 3 ms 256 KB
01-22.txt 3 ms 256 KB
01-23.txt 3 ms 256 KB
01-24.txt 3 ms 256 KB
01-25.txt 3 ms 256 KB
01-26.txt 3 ms 256 KB
02-01.txt 3 ms 256 KB
02-02.txt 118 ms 8064 KB
02-03.txt 118 ms 8064 KB
02-04.txt 118 ms 8064 KB
02-05.txt 117 ms 8064 KB
02-06.txt 118 ms 8064 KB
02-07.txt 118 ms 8064 KB
02-08.txt 118 ms 8064 KB
02-09.txt 118 ms 8064 KB
02-10.txt 117 ms 8064 KB
02-11.txt 118 ms 8064 KB
02-12.txt 118 ms 8064 KB
02-13.txt 119 ms 8064 KB
02-14.txt 118 ms 8064 KB
02-15.txt 118 ms 8064 KB
02-16.txt 117 ms 8064 KB
02-17.txt 118 ms 8064 KB
02-18.txt 119 ms 8064 KB
02-19.txt 118 ms 8064 KB
02-20.txt 118 ms 8064 KB
02-21.txt 117 ms 8064 KB
02-22.txt 119 ms 8064 KB
02-23.txt 118 ms 8064 KB
02-24.txt 117 ms 8064 KB
02-25.txt 118 ms 8064 KB
02-26.txt 118 ms 8064 KB
02-27.txt 118 ms 8064 KB
02-28.txt 117 ms 8064 KB
02-29.txt 118 ms 8064 KB
02-30.txt 118 ms 8064 KB
02-31.txt 117 ms 8064 KB
02-32.txt 119 ms 8064 KB
02-33.txt 117 ms 8064 KB
02-34.txt 117 ms 8064 KB
02-35.txt 118 ms 8064 KB
02-36.txt 118 ms 8064 KB
02-37.txt 117 ms 8064 KB
02-38.txt 117 ms 8064 KB
02-39.txt 117 ms 8064 KB
02-40.txt 119 ms 8064 KB
sample-01.txt 3 ms 256 KB
sample-02.txt 117 ms 8064 KB
sample-03.txt 8 ms 1280 KB