Submission #1072755

#TimeUsernameProblemLanguageResultExecution timeMemory
1072755CyanberryGlobal Warming (CEOI18_glo)C++14
0 / 100
2052 ms1360 KiB
// earth cooling #include <bits/stdc++.h> using namespace std; int main() { int dayc, limit; cin>>dayc>>limit; int days[dayc]; for (int i = 0; i < dayc; ++i) { cin>>days[i]; } if (limit <= 50) { int leftBound, rightBound, modifier, out = 0; for (leftBound = 0; leftBound < dayc; ++leftBound) { for (rightBound = leftBound + 1; rightBound <= dayc; ++rightBound) { for (modifier = 0; modifier < limit; ++modifier) { vector<int> LISs; for (int i = 0; i < dayc; ++i) { int l = -1, r = LISs.size(); while (r - l > 1) { int m = (r+l)/2; if (LISs[m] >= days[i] + (i < rightBound && i > leftBound) * modifier) { r = m; } else { l = m; } } if (r == LISs.size()) { LISs.push_back(days[i] + (i < rightBound && i > leftBound) * modifier); } else { LISs[r] = min(LISs[r], days[i] + (i < rightBound && i > leftBound) * modifier); } } out = max(out, int(LISs.size())); } } } cout<<out; // } else if (days <= 1000) { } else { int LISs[2][dayc]; int end1 = 0; for (int i=0; i<dayc; ++i) { LISs[0][i] = INT_MAX; LISs[1][i] = INT_MAX; } for (int i=0; i < dayc; ++i) { if (end1 > 0) { int l = -1, r = end1; while (r - l > 1) { int m = (r+l)/2; if (LISs[1][m] >= days[i]) { r = m; } else { l = m; } } LISs[1][r] = min(LISs[1][r], days[i]); l = -1, r = end1; while (r - l > 1) { int m = (r+l)/2; if (LISs[0][m] >= days[i]) { r = m; } else { l = m; } } if (LISs[0][r] == -1 || LISs[1][r]) ++end1; LISs[0][r] = min(LISs[0][r], days[i]); LISs[1][r] = min(LISs[1][r], days[i]); LISs[1][end1+1] = min(LISs[1][end1+1], days[i]); } else { end1 = 1; LISs[0][0] = days[i]; LISs[1][0] = days[i]; } } cout<<end1; } }

Compilation message (stderr)

glo.cpp: In function 'int main()':
glo.cpp:28:31: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   28 |                         if (r == LISs.size()) {
      |                             ~~^~~~~~~~~~~~~~
#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...