Submission #1284767

#TimeUsernameProblemLanguageResultExecution timeMemory
1284767KhanhDangGlobal Warming (CEOI18_glo)C++17
10 / 100
40 ms2808 KiB
#include<bits/stdc++.h> using namespace std; #define ll long long #define pll pair<ll, ll> #define pii pair<int, int> #define fi first #define se second #define all(v) (v).begin(), (v).end() #define Unique(v) sort(all(v)); (v).erase(unique(all(v)), (v).end()); const int N = 2e5 + 5; int n, x; int a[2][N]; int f[2][N]; int res[2]; int Find(int t, int x) { int l = 1, r = res[t], j = 0; while (l <= r) { int m = (l + r) >> 1; if (x > f[t][m]) { j = m; l = m + 1; } else r = m - 1; } return j; } signed main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); #define task "bseq" if (fopen(task".inp", "r")) { freopen(task".inp", "r", stdin); freopen(task".out", "w", stdout); } if (fopen("task.inp", "r")) { freopen("task.inp", "r", stdin); freopen("task.out", "w", stdout); } cin>>n>>x; for (int i = 1; i <= n; i++) { cin>>a[0][i]; a[1][i] = a[0][i] + x; } f[0][1] = a[0][1]; res[0] = 1; f[1][1] = a[1][1]; res[1] = 1; for (int i = 2; i <= n; i++) { int j = Find(0, a[0][i]); int k = max(Find(0, a[1][i]), Find(1, a[1][i])); if (j == res[0]) f[0][++res[0]] = a[0][i]; else if (a[0][i] < f[0][j + 1]) f[0][j + 1] = a[0][i]; if (k == res[1]) f[1][++res[1]] = a[1][i]; else if (a[1][i] < f[1][k + 1]) f[1][k + 1] = a[1][i]; } cout<<max(res[0], res[1]); cerr<<setprecision(3)<<fixed<<"Time elapsed: "<< 1.0 * clock() / CLOCKS_PER_SEC <<"s\n"; }

Compilation message (stderr)

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