답안 #381730

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
381730 2021-03-25T19:11:20 Z mohamedsobhi777 운세 보기 2 (JOI14_fortune_telling2) C++14
0 / 100
2 ms 364 KB
#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;
       vi b(k) ; 
       for(auto &u : b)cin >> u; 
       ll sum = 0;
       for(int i = 0 ;i <  n ;++ i){
              ll L = min(a[i].f , a[i].s) ; 
              ll R = max(a[i].f , a[i].s) ; 
              int lst = -1 ; 
              int cnt = 0 ; 
              for(int j = 0 ;j < k ;++ j){
                     if(b[j] >= L && b[j] < R){
                            lst = j; 
                            cnt = 0 ; 
                     }else if(b[j] >= R){
                            ++ cnt ; 
                     }
              }
              if(cnt&1)swap(a[i].f , a[i].s) ; 
              sum += a[i].f ; 
       }
       cout << sum ;
       return 0;
}

Compilation message

fortune_telling2.cpp: In function 'int main()':
fortune_telling2.cpp:43:19: warning: variable 'lst' set but not used [-Wunused-but-set-variable]
   43 |               int lst = -1 ;
      |                   ^~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -