Submission #141666

# Submission time Handle Problem Language Result Execution time Memory
141666 2019-08-08T17:19:12 Z karma Exhibition (JOI19_ho_t2) C++11
100 / 100
67 ms 4600 KB
#include<bits/stdc++.h>
#define FileName      "test"
#define ll            long long
#define ld            long double
#define ull           unsigned long long
#define Debug(x)      cerr << #x << "is " << x << '\n';
#define pb            emplace_back
#define mp            make_pair
#define x             first
#define y             second
//#define LuckyAurora
//#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
//#pragma GCC optimization ("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")

using namespace std;

template<typename T> inline void Cin(T &x)
{
    char c;
    T sign = 1;
    x = 0;
    for (c = getchar(); c < '0' || c > '9'; c = getchar())
        if (c == '-') sign = -1;
    for (; c >= '0' && c <= '9'; c = getchar())
        x = x * 10 + c - '0';
    x *= sign;
}
template <typename T> inline void Out(T x) {if(x > 9) Out(x / 10); putchar(x % 10 + '0');}
template <typename T> inline void Cout(T x, char c) {if(x < 0) putchar('-'); x = abs(x); Out(x); putchar(c);}
template <typename T, typename... Args> inline void Cin(T& a, Args&... args) {Cin(a);Cin(args...);}
template <typename T, typename... Args> inline void Cout(T a, char c, Args... args) {Cout(a, c);Cout(args...);}

typedef pair<int, int> pii;
const int N = int(1e5) + 1;
const int logN = 60;

int n, m, fr[N], res;
struct TIrene{int s, v;} a[N];

void Enter()
{
     cin >> n >> m;
     for(int i = 0; i < n; ++i) cin >> a[i].s >> a[i].v;
     for(int i = 0; i < m; ++i) cin >> fr[i];
     sort(fr, fr + m, greater<int>());
     sort(a, a + n, [](const TIrene& a, const TIrene& b) {
             return a.v > b.v || (a.v == b.v && a.s > b.s);
          });
}

void Solve()
{
     int j = 0;
     for(int i = 0; i < m; ++i) {
        while(a[j].s > fr[i] && j < n) ++j;
        if(j < n) ++res, ++j;
     }
     cout << res;
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    if(fopen(FileName".inp", "r")) {
        freopen(FileName".inp", "r", stdin);
        freopen(FileName".out", "w", stdout);
    }

    /*int nTest; cin >> nTest;
    while(nTest --)*/ Enter(), Solve();

    return 0;
}

Compilation message

joi2019_ho_t2.cpp:13:0: warning: ignoring #pragma GCC optimization [-Wunknown-pragmas]
 #pragma GCC optimization ("O3")
 
joi2019_ho_t2.cpp: In function 'int main()':
joi2019_ho_t2.cpp:68:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
         freopen(FileName".inp", "r", stdin);
         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
joi2019_ho_t2.cpp:69:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
         freopen(FileName".out", "w", stdout);
         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 504 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 380 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 2 ms 376 KB Output is correct
18 Correct 2 ms 380 KB Output is correct
19 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 504 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 380 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 2 ms 376 KB Output is correct
18 Correct 2 ms 380 KB Output is correct
19 Correct 2 ms 376 KB Output is correct
20 Correct 3 ms 376 KB Output is correct
21 Correct 3 ms 376 KB Output is correct
22 Correct 3 ms 376 KB Output is correct
23 Correct 3 ms 376 KB Output is correct
24 Correct 3 ms 376 KB Output is correct
25 Correct 3 ms 376 KB Output is correct
26 Correct 2 ms 376 KB Output is correct
27 Correct 3 ms 376 KB Output is correct
28 Correct 3 ms 376 KB Output is correct
29 Correct 3 ms 504 KB Output is correct
30 Correct 3 ms 376 KB Output is correct
31 Correct 3 ms 376 KB Output is correct
32 Correct 2 ms 376 KB Output is correct
33 Correct 2 ms 376 KB Output is correct
34 Correct 3 ms 376 KB Output is correct
35 Correct 3 ms 376 KB Output is correct
36 Correct 3 ms 376 KB Output is correct
37 Correct 3 ms 380 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 504 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 380 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 2 ms 376 KB Output is correct
18 Correct 2 ms 380 KB Output is correct
19 Correct 2 ms 376 KB Output is correct
20 Correct 3 ms 376 KB Output is correct
21 Correct 3 ms 376 KB Output is correct
22 Correct 3 ms 376 KB Output is correct
23 Correct 3 ms 376 KB Output is correct
24 Correct 3 ms 376 KB Output is correct
25 Correct 3 ms 376 KB Output is correct
26 Correct 2 ms 376 KB Output is correct
27 Correct 3 ms 376 KB Output is correct
28 Correct 3 ms 376 KB Output is correct
29 Correct 3 ms 504 KB Output is correct
30 Correct 3 ms 376 KB Output is correct
31 Correct 3 ms 376 KB Output is correct
32 Correct 2 ms 376 KB Output is correct
33 Correct 2 ms 376 KB Output is correct
34 Correct 3 ms 376 KB Output is correct
35 Correct 3 ms 376 KB Output is correct
36 Correct 3 ms 376 KB Output is correct
37 Correct 3 ms 380 KB Output is correct
38 Correct 61 ms 4364 KB Output is correct
39 Correct 59 ms 4444 KB Output is correct
40 Correct 55 ms 4472 KB Output is correct
41 Correct 63 ms 4472 KB Output is correct
42 Correct 62 ms 4472 KB Output is correct
43 Correct 61 ms 4348 KB Output is correct
44 Correct 67 ms 4360 KB Output is correct
45 Correct 64 ms 4344 KB Output is correct
46 Correct 61 ms 4368 KB Output is correct
47 Correct 55 ms 4088 KB Output is correct
48 Correct 55 ms 4036 KB Output is correct
49 Correct 50 ms 3576 KB Output is correct
50 Correct 50 ms 3576 KB Output is correct
51 Correct 62 ms 4472 KB Output is correct
52 Correct 62 ms 4344 KB Output is correct
53 Correct 61 ms 4344 KB Output is correct
54 Correct 54 ms 4472 KB Output is correct
55 Correct 63 ms 4344 KB Output is correct
56 Correct 40 ms 3064 KB Output is correct
57 Correct 25 ms 1784 KB Output is correct
58 Correct 39 ms 3192 KB Output is correct
59 Correct 41 ms 3108 KB Output is correct
60 Correct 24 ms 1656 KB Output is correct
61 Correct 39 ms 2680 KB Output is correct
62 Correct 62 ms 4344 KB Output is correct
63 Correct 62 ms 4600 KB Output is correct
64 Correct 62 ms 4472 KB Output is correct
65 Correct 62 ms 4472 KB Output is correct
66 Correct 63 ms 4472 KB Output is correct
67 Correct 62 ms 4472 KB Output is correct
68 Correct 63 ms 4344 KB Output is correct
69 Correct 63 ms 4344 KB Output is correct
70 Correct 65 ms 4492 KB Output is correct
71 Correct 60 ms 4472 KB Output is correct
72 Correct 63 ms 4344 KB Output is correct
73 Correct 59 ms 4344 KB Output is correct