Submission #1111675

#TimeUsernameProblemLanguageResultExecution timeMemory
1111675khoaha123Teams (CEOI11_tea)C++17
0 / 100
392 ms262144 KiB
#include <bits/stdc++.h> #define endl '\n' #define ii pair<int,int> #define task "DIVTEAM" #define all(x) x.begin(),x.end() #define int long long using namespace std; const int N = 1e6 + 5; const int mod = 1e9 + 7; const int INF = 1e9; const double EPS = 1e-9; const int dx[2] = {1,0}; const int dy[2] = {0,1}; int n,a[N]; vector<int> b[N]; vector<vector<int>> ans; int dp[N],pos[N]; int check(int T){ dp[0] = 0; for (int i = 1; i <= n; ++i){ if (i >= a[i] && i - pos[i - a[i]] <= T) dp[i] = dp[pos[i - a[i]]] + 1; pos[i] = (dp[pos[i-1]] > dp[i] ? pos[i-1] : i); } return dp[n]; } signed main() { ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0); if (fopen(task".INP","r")){ freopen(task".INP","r",stdin); freopen(task".OUT","w",stdout); } cin >> n; for (int i = 1; i <= n; ++i){ cin >> a[i]; b[a[i]].push_back(i); } sort(a+1,a+1+n); int result = check(n); int l = 0,r = n; while (r - l > 1){ int mid = (l + r) >> 1; if (check(mid) == result) r = mid; else l = mid; } check(r); int u = n; while (u){ int t = pos[u -a[u]]; vector<int> x; while (u > t){ x.push_back(b[a[u]].back()); b[a[u]].pop_back(); u--; } ans.push_back(x); } cout << ans.size() << endl; for (auto f : ans){ cout << f.size() << ' '; for (auto g : f) cout << g << ' '; cout << endl; } return 0; }

Compilation message (stderr)

tea.cpp: In function 'int main()':
tea.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".INP","r",stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
tea.cpp:37:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   37 |         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...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...