1 solutions
-
0
C++ :
#include <bits/stdc++.h> #define N 100005 using namespace std; int c[N]; bool a[N]; int main(){ long long n,m,w,ans = 0,tmp = 0; cin >> n >> m >> w; for (int i = 1;i<=n;i++) cin >> c[i]; for (int i = 1;i<=m;i++){ int id; cin >> id; a[id] = !a[id]; if (a[id]) tmp += c[id]; else tmp -=c[id]; if (tmp >w){ cout << "Oh, My God!"; return 0; } else ans = max(ans,tmp); } cout << ans; return 0; }
- 1
Information
- ID
- 183
- Time
- 1000ms
- Memory
- 128MiB
- Difficulty
- (None)
- Tags
- # Submissions
- 0
- Accepted
- 0
- Uploaded By