#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define finish(x) return cout << x << endl, 0;
int n, q, x, y;
vector <pair <int, int> > a;
vector <int> b;
int main(){
ios_base::sync_with_stdio(0);
cin.tie(NULL);
cout.tie(NULL);
cin >> n >> q;
for(int i = 0 ; i < n && cin >> x >> y ; i++)
a.push_back(make_pair(x, y));
for(int i = 0 ; i < q && cin >> x ; i++)
b.push_back(x);
ll ans = 0;
for(auto &i : a){
x = i.first, y = i.second;
for(int j = 0 ; j < b.size() ; j++){
if(b[j] >= x)
swap(x, y);
}
ans += x;
}
cout << ans << endl;
return 0;
}
Compilation message
fortune_telling2.cpp: In function 'int main()':
fortune_telling2.cpp:22:27: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int j = 0 ; j < b.size() ; j++){
~~^~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
248 KB |
Output is correct |
2 |
Correct |
6 ms |
484 KB |
Output is correct |
3 |
Correct |
8 ms |
612 KB |
Output is correct |
4 |
Correct |
9 ms |
612 KB |
Output is correct |
5 |
Correct |
9 ms |
612 KB |
Output is correct |
6 |
Correct |
8 ms |
824 KB |
Output is correct |
7 |
Correct |
9 ms |
836 KB |
Output is correct |
8 |
Correct |
5 ms |
940 KB |
Output is correct |
9 |
Correct |
7 ms |
956 KB |
Output is correct |
10 |
Correct |
7 ms |
996 KB |
Output is correct |
11 |
Correct |
11 ms |
1008 KB |
Output is correct |
12 |
Correct |
8 ms |
1040 KB |
Output is correct |
13 |
Correct |
7 ms |
1072 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
248 KB |
Output is correct |
2 |
Correct |
6 ms |
484 KB |
Output is correct |
3 |
Correct |
8 ms |
612 KB |
Output is correct |
4 |
Correct |
9 ms |
612 KB |
Output is correct |
5 |
Correct |
9 ms |
612 KB |
Output is correct |
6 |
Correct |
8 ms |
824 KB |
Output is correct |
7 |
Correct |
9 ms |
836 KB |
Output is correct |
8 |
Correct |
5 ms |
940 KB |
Output is correct |
9 |
Correct |
7 ms |
956 KB |
Output is correct |
10 |
Correct |
7 ms |
996 KB |
Output is correct |
11 |
Correct |
11 ms |
1008 KB |
Output is correct |
12 |
Correct |
8 ms |
1040 KB |
Output is correct |
13 |
Correct |
7 ms |
1072 KB |
Output is correct |
14 |
Correct |
423 ms |
1624 KB |
Output is correct |
15 |
Correct |
1755 ms |
2372 KB |
Output is correct |
16 |
Execution timed out |
3025 ms |
3256 KB |
Time limit exceeded |
17 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
248 KB |
Output is correct |
2 |
Correct |
6 ms |
484 KB |
Output is correct |
3 |
Correct |
8 ms |
612 KB |
Output is correct |
4 |
Correct |
9 ms |
612 KB |
Output is correct |
5 |
Correct |
9 ms |
612 KB |
Output is correct |
6 |
Correct |
8 ms |
824 KB |
Output is correct |
7 |
Correct |
9 ms |
836 KB |
Output is correct |
8 |
Correct |
5 ms |
940 KB |
Output is correct |
9 |
Correct |
7 ms |
956 KB |
Output is correct |
10 |
Correct |
7 ms |
996 KB |
Output is correct |
11 |
Correct |
11 ms |
1008 KB |
Output is correct |
12 |
Correct |
8 ms |
1040 KB |
Output is correct |
13 |
Correct |
7 ms |
1072 KB |
Output is correct |
14 |
Correct |
423 ms |
1624 KB |
Output is correct |
15 |
Correct |
1755 ms |
2372 KB |
Output is correct |
16 |
Execution timed out |
3025 ms |
3256 KB |
Time limit exceeded |
17 |
Halted |
0 ms |
0 KB |
- |