답안 #888332

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
888332 2023-12-17T01:41:10 Z hwy 운세 보기 2 (JOI14_fortune_telling2) C++17
0 / 100
0 ms 348 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	ll n, k;
	vector<pair<ll, ll>> cards;
	vector<ll> ops;
	ll ans = 0;
	ll curr_num;
	
	for (ll i = 0; i < n; i++) {
		ll a, b;
		cin >> a >> b;
		cards.push_back({a, b});
	}
	
	for (ll i = 0; i < k; i++) {
		ll temp;
		cin >> temp;
		ops.push_back(temp);
	}
	
	for (ll i = 0; i < n; i++) {
		curr_num = cards[i].first;
		for (ll j = 0; j < k; j++) {
			if (curr_num <= ops[j]) {
				if (curr_num == cards[i].first)
					curr_num = cards[i].second;
				else if (curr_num == cards[i].second)
					curr_num = cards[i].first;
			}
		}
		ans += curr_num;
	}
	cout << ans;
	return 0;
}
				

Compilation message

fortune_telling2.cpp: In function 'int main()':
fortune_telling2.cpp:15:19: warning: 'n' may be used uninitialized in this function [-Wmaybe-uninitialized]
   15 |  for (ll i = 0; i < n; i++) {
      |                 ~~^~~
fortune_telling2.cpp:21:19: warning: 'k' may be used uninitialized in this function [-Wmaybe-uninitialized]
   21 |  for (ll i = 0; i < k; i++) {
      |                 ~~^~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -