Submission #936824

#TimeUsernameProblemLanguageResultExecution timeMemory
936824PagodePaivaTeams (IOI15_teams)C++17
0 / 100
4045 ms12648 KiB
#include "teams.h" #include<bits/stdc++.h> using namespace std; int n; vector <pair <int, int>> v; void init(int N, int A[], int B[]) { n = N; for(int i = 0;i < n;i++){ v.push_back({A[i], B[i]}); } return; } int can(int M, int K[]) { vector <int> k; int m = M; for(int i = 0;i < m;i++){ k.push_back(K[i]); } sort(k.begin(), k.end()); vector <pair <int, int>> conc; for(int i = 0;i < n;i++){ if(v[i].second < k[0] or v[i].first > k[m-1]) continue; int l = 0, r = m-1; while(r-l > 1){ int mid = (l+r)/2; if(k[mid] > v[i].second){ r = mid-1; } else l = mid; } if(k[r] <= v[i].second) l = r; else r = l; int a = l; l = 0; r = m-1; while(r - l > 1){ int mid = (l+r)/2; if(k[mid] < v[i].first){ l = mid+1; } else r = mid; } if(v[i].first <= k[l]) r = l; else l = r; int b = l; conc.push_back({k[b], k[a]}); // cout << a << ' ' << b << endl; } sort(conc.begin(), conc.end()); int l = conc.size(); l--; reverse(k.begin(), k.end()); for(auto x : k){ int cnt = x; while(cnt > 0){ if(l < 0) return 0; // cout << v[l].first << ' ' << v[l].second << ' ' << x << endl; if(conc[l].first <= x and x <= conc[l].second){ cnt--; } l--; } } return 1; }

Compilation message (stderr)

teams.cpp: In function 'int can(int, int*)':
teams.cpp:53:19: warning: conversion from 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} to 'int' may change value [-Wconversion]
   53 |  int l = conc.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...