Submission #345044

#TimeUsernameProblemLanguageResultExecution timeMemory
345044nishuzLightning Rod (NOI18_lightningrod)C++14
4 / 100
2004 ms174564 KiB
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n, ans = 0; cin >> n; vector <pair <int, int>> a(n); for (int i = 0; i < n; ++i) cin >> a[i].first >> a[i].second; for (int i = 0; i < n; ++i) { if (a[i].second) ++ans; else ans += ((!i || !a[i-1].second) && (i == n-1 || !a[i+1].second)); } cout << ans << '\n'; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...