제출 #381695

#제출 시각아이디문제언어결과실행 시간메모리
381695mohamedsobhi777운세 보기 2 (JOI14_fortune_telling2)C++14
4 / 100
3014 ms620 KiB
#include <bits/stdc++.h>

using namespace std;

#define vi vector<int>
#define vll vector<ll>
#define vii vector<pair<int, int>>
#define pii pair<int, int>
#define pll pair<ll, ll>
#define loop(_) for (int __ = 0; __ < (_); ++__)
#define pb push_back
#define f first
#define s second
#define sz(_) ((int)_.size())
#define all(_) _.begin(), _.end()
#define lb lower_bound
#define ub upper_bound

using ll = long long;
using ld = long double;

const int N = 1e5 + 7;
const ll mod = 1e9 + 7;

int n, k;

int main()
{
       ios_base::sync_with_stdio(0);
       cin.tie(0);
#ifndef ONLINE_JUDGE
#endif
       cin >> n >> k;
       vii a(n);
       for (int i = 0; i < n; ++i)
              cin >> a[i].f >> a[i].s;
       ll sum = 0;
       for (int i = 0; i < n; ++i)
       {
              sum += a[i].f;
       }
       while (k--)
       {
              int x;
              cin >> x;
              for (int i = 0; i < n; ++i)
              {
                     if (a[i].f <= x)
                     {
                            sum -= a[i].f;
                            swap(a[i].f, a[i].s);
                            sum += a[i].f;
                     }
              }
       }
       cout << sum;
       return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...