제출 #128130

#제출 시각아이디문제언어결과실행 시간메모리
128130SortingTeams (IOI15_teams)C++14
0 / 100
189 ms25444 KiB
#include <bits/stdc++.h> using namespace std; const int N = 5e5 + 7; int n; int *a, *b; multiset<int> st; vector<pair<int, int> > v; void init(int _n, int *_a, int *_b){ n = _n; a = _a; b = _b; for(int i = 0; i < n; i++){ v.push_back({a[i], i + 1}); v.push_back({b[i] + 1, -i - 1}); } sort(v.begin(), v.end()); } bool boo[N]; bool can(int m, int *k){ for(int i = 0; i < n; i++){ boo[i] = false; } sort(k, k + m); int j = 0; for(int i = 0; i < (int)v.size(); i++){ pair<int, int> p = v[i]; int idx; if(p.second > 0){ idx = -p.second - 1; boo[idx] = true; st.insert(b[idx]); } else{ idx = p.second - 1; if(boo[idx]){ st.erase(b[idx]); boo[idx] = false; } } if(i == (int)v.size() - 1 || p.first != v[i + 1].first){ while(j < m && k[j] >= p.first && (i == (int)v.size() - 1 || k[j] < v[i + 1].first)){ if(st.size() < k[j]){ return 0; } for(int r = 0; r < k[j]; r++){ st.erase(st.begin()); } j++; } } } return 1; }

컴파일 시 표준 에러 (stderr) 메시지

teams.cpp: In function 'bool can(int, int*)':
teams.cpp:57:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     if(st.size() < k[j]){
        ~~~~~~~~~~^~~~~~
teams.cpp:44:11: warning: array subscript is below array bounds [-Warray-bounds]
    boo[idx] = true;
    ~~~~~~~^
teams.cpp:49:14: warning: array subscript is below array bounds [-Warray-bounds]
    if(boo[idx]){
       ~~~~~~~^
teams.cpp:51:12: warning: array subscript is below array bounds [-Warray-bounds]
     boo[idx] = false;
     ~~~~~~~^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...