Submission #888332

#TimeUsernameProblemLanguageResultExecution timeMemory
888332hwyFortune Telling 2 (JOI14_fortune_telling2)C++17
0 / 100
0 ms348 KiB
#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 (stderr)

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++) {
      |                 ~~^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...