Submission #1040793

#TimeUsernameProblemLanguageResultExecution timeMemory
1040793khanhtbExhibition (JOI19_ho_t2)C++17
100 / 100
35 ms4692 KiB
#pragma GCC optimize("Ofast,unroll-loops") #include <bits/stdc++.h> #define ll long long #define ull unsigned long long #define ld long double #define pb push_back #define pf push_front #define vi vector<ll> #define vii vector<vi> #define pll pair<ll, ll> #define vpll vector<pll> #define all(a) a.begin(), a.end() #define fi first #define se second using namespace std; const ll mod = 998244353; const ll inf = 1e18; const ll blocksz = 320; const ll N = 1e5+8; pair<int,int> a[N]; int n,m,c[N]; void solve(){ cin >> n >> m; for(int i = 1; i <= n; i++) cin >> a[i].fi >> a[i].se; for(int i = 1; i <= m; i++) cin >> c[i]; sort(a+1,a+n+1,[&](pair<int,int> a, pair<int,int> b){ return a.se < b.se || (a.se == b.se && a.fi < b.fi); }); sort(c+1,c+m+1); int j = n; ll ans = 0; for(int i = m; i >= 1; i--){ while(j >= 1 && a[j].fi > c[i]) j--; if(j > 0) ans++; j--; } cout << ans; } signed main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); if (fopen("test.inp", "r")) { freopen("test.inp", "r", stdin); freopen("test.out", "w", stdout); } ll T = 1; // cin >> T; for (ll i = 1; i <= T; i++) { solve(); cout << '\n'; } }

Compilation message (stderr)

joi2019_ho_t2.cpp: In function 'int main()':
joi2019_ho_t2.cpp:44:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   44 |         freopen("test.inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
joi2019_ho_t2.cpp:45:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   45 |         freopen("test.out", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...