int main()
{
	ifstream fin("marathon.in");
	ofstream fout("marathon.out");

	int N; 
	fin >> N;
	points.resize(N);
	for (int i = 0; i < N; ++i)
	{
		fin >> points[i].first >> points[i].second;
	}

	T.resize(N - 2);
	res.resize(N - 2);

	T[0].first = 0;
	T[0].second =  dist_cont(2, N-1);
	res[0] = T[0].first + T[0].second + dist_two(0, 2);
	int result = res[0];

	for (int k = 1; k <= N - 3; ++k)
	{
		T[k].first = T[k - 1].first + dist_two(k - 1, k);
		T[k].second = T[k - 1].second - dist_two(k + 1, k+2);
		res[k] = T[k].first + T[k].second + dist_two(k, k + 2);
		result = min(result, res[k]);
	}
	fout << result << '\n';
	
	return 0;
}
int main() {
    ios::sync_with_stdio(0);
    double d;
    int m, tc = 1;
    while( cin >> d >> m) {
        cout << "Case " << tc++ << ":" << endl;
        memo.clear(); memo.resize(105, -1);
        prices.clear(); prices.resize(m + 1);
        prices[0].first = 1; prices[0].second = (d + eps) * 100;
        for(int i = 1; i <= m; i++) {
            int tmp; cin >> tmp >> d;
            prices[i].first = tmp; prices[i].second = (d + eps) * 100;
        }
        string str;
        cin.get();
        getline(cin, str);
        stringstream ss(str);
        int tmp;
        while(ss >> tmp) {
            cout << "Buy " << tmp << " for $" << fixed << setprecision(2) << (double)solve(tmp) / 100 << endl;
        }
    }

    return 0;
}
示例#3
0
文件: curling.cpp 项目: nicomazz/oii
int main(int argc, const char * argv[])
{
#ifndef TEST
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
#endif

    scanInt(N);
    succ.resize(N+1), best_succ.resize(N+1);
    int da, a;
    int fino = (N*(N-1))/2;
    while ( fino--)
    {
        scanInt(da); scanInt(a);
        graph[da].push_back(a);
    }
    
    for (int i = 1; i <=N; i++)
    {
        visited[i-1] = false;
        if (dfs(partenza = i, 1)) break;;
    }
    
    dfs(from_best,1,best_len);
    
    writeInt(best_len-1);
    printf("\n");
    int att = from_best;
    while ( succ[att] != -1)
    {
        writeInt(att); printf(" "); writeInt(succ[att]);
        printf("\n");
        att = succ[att];
    }
    
    return 0;
}
示例#4
0
int main() {
    int n;
    cin >> n;
    vector<pii> x(n);
    for (int i = 0; i < n; ++i) {
        cin >> x[i].first >> x[i].second;
    }
    sort(x.begin(), x.end());
    res = x;
    out(x, 0, x.size());
/*    for (int i = 0; i < res.size(); ++i)
        swap(res[i].first, res[i].second);
    res = out(res);
    for (int i = 0; i < res.size(); ++i)
        swap(res[i].first, res[i].second);
    res.push_back(pii(-1e9 - 10, 0));
    res = out(res);*/
    sort(res.begin(), res.end());
    res.resize(unique(res.begin(), res.end()) - res.begin());
    cout << res.size() << endl;
    for (int i = 0; i < res.size(); ++i)
        cout << res[i].first << " " << res[i].second << endl;
    return 0;
}