Submission #1215403

#TimeUsernameProblemLanguageResultExecution timeMemory
1215403sunflowerExhibition (JOI19_ho_t2)C++17
0 / 100
0 ms396 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define MASK(x) (1LL << (x)) #define BIT(x, i) (((x) >> (i)) & 1) #define SZ(x) ((int) (x).size()) #define ALL(a) (a).begin(), (a).end() #define FOR(i, a, b) for (int i = (a), _b = (b); i <= _b; ++i) #define FORD(i, a, b) for (int i = (a), _b = (b); i >= _b; --i) #define REP(i, n) for (int i = 0, _n = (n); i < _n; ++i) #define debug(x) cout << "[" << #x << " = " << (x) << "]" << endl #define left __left #define right __right #define prev __prev #define next __next #define fi first #define se second template <class X, class Y> bool maximize(X &x, Y y) { if (x < y) return x = y, true; else return false; } template <class X, class Y> bool minimize(X &x, Y y) { if (x > y) return x = y, true; else return false; } const int inf = (int) 1e9 + 7; #define MAX_N 100'100 int numPic, numFrame; int frame[MAX_N + 2]; struct Pic { int sz, val; void input() { cin >> sz >> val; } void output() { cout << sz << " " << val << endl; } bool operator < (const Pic &other) const { if (val != other.val) return val < other.val; return sz < other.sz; } } pic[MAX_N + 2]; namespace subtask2 { bool check() { return (max(numPic, numFrame) <= 1000); } int dp[1010][1010]; void solve() { int ans = 0; FOR(i, 1, numPic) FOR(j, 1, numFrame) { if (pic[i].sz <= frame[j]) { dp[i][j] = 1; maximize(dp[i][j], dp[i][j - 1]); maximize(dp[i][j], dp[i - 1][j - 1] + 1); } maximize(ans, dp[i][j]); } cout << ans; } } int main() { ios_base::sync_with_stdio(false);cin.tie(nullptr); #define task "test" if (fopen(task".inp","r")) { freopen(task".inp","r",stdin); freopen(task".out","w",stdout); } cin >> numPic >> numFrame; /// frame & val inc , not sz & val inc; huhu; FOR(i, 1, numPic) pic[i].input(); FOR(i, 1, numFrame) cin >> frame[i]; sort(pic + 1, pic + 1 + numPic); sort(frame + 1, frame + 1 + numFrame); if (subtask2 :: check()) return subtask2 :: solve(), 0; return 0; } /* Discipline - Calm */

Compilation message (stderr)

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