답안 #872671

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
872671 2023-11-13T14:11:03 Z vjudge1 Sure Bet (CEOI17_sure) C++11
60 / 100
57 ms 3360 KB
#include <bits/stdc++.h>
using namespace std;
using ll = long long;


void print(ll a) {
	if(a < 10) cout << "0.000" << a;
	else if(a < 100) cout << "0.00" << a;
	else if(a < 1000) cout << "0.0" << a;
	else if(a < 10000) cout << "0." << a;
	else cout << a/10000 << "." << a%10000;
	return; 
	
}

int manipulateString(const std::string& input) {
    // Noktadan sonraki karakter sayısını bulma
    size_t dotIndex = input.find('.');
    size_t decimalCount = (dotIndex != std::string::npos) ? input.size() - dotIndex - 1 : 0;

    // Nokta içeriyorsa noktayı sil
    std::string result = input;
    result.erase(std::remove(result.begin(), result.end(), '.'), result.end());

    // Sonuna 4 - decimalCount kadar '0' ekleme
    result.append(4 - decimalCount, '0');

    // Noktadan önce sadece 0 varsa sil
    if (result.find_first_not_of('0') == dotIndex) {
        result.erase(0, dotIndex);
    }

    // Elde edilen sonucu inte çevirme
    int finalResult = std::stoi(result);

    // Sonucu integer olarak döndürme
    return finalResult;
}

int main() {
	cout.precision(12);
	int n;
	cin >> n;

	vector<ll> v1(n), v2(n);
	for(int i = 0; i<n; i++) {
		string a, b;
		cin >> a >> b;

		v1[i] = manipulateString(a);
		v2[i] = manipulateString(b);
	}

	sort(v1.begin(), v1.end()); sort(v2.begin(), v2.end());
	reverse(v1.begin(), v1.end()); reverse(v2.begin(), v2.end());

	ll ptr1 = 0, ptr2 = 0;
	ll val1 = 0, val2 = 0, rem = 0;
	ll ans = 0;

	/*
	for(int i : v1) cout << i << " ";
	cout << "\n";
	for(int i : v2) cout << i << " ";
	cout << "\n";
	*/
	while(ptr1 <= n && ptr2 <= n) {
		if(val1 < val2) {
			val1 += v1[ptr1];
			ptr1++;
			rem += 10000;
		}

		else{
			val2+= v2[ptr2];
			ptr2++;
			rem += 10000;
		}

		ans = max(ans, min(val1, val2) - rem);

	}
	print(ans);


}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 344 KB Output is correct
13 Correct 1 ms 468 KB Output is correct
14 Correct 1 ms 448 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 444 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 344 KB Output is correct
13 Correct 1 ms 468 KB Output is correct
14 Correct 1 ms 448 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 444 KB Output is correct
17 Correct 57 ms 3268 KB Output is correct
18 Correct 57 ms 3156 KB Output is correct
19 Incorrect 57 ms 3360 KB Output isn't correct
20 Halted 0 ms 0 KB -