제출 #992782

#제출 시각아이디문제언어결과실행 시간메모리
992782n3rm1nHedgehog Daniyar and Algorithms (IZhO19_sortbooks)C++17
13 / 100
343 ms18008 KiB
#include<bits/stdc++.h> #define endl '\n' #define ll long long using namespace std; const long long MAXN = 1e6+10; void speed() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); } long long n, m; long long a[MAXN], w; long long l, r, k; long long go[MAXN]; void read() { cin >> n >> m; for (long long i = 1; i <= n; ++ i) { cin >> a[i]; } } int marked[5005]; void solve5000() { for (long long i = 1; i <= m; ++ i) { cin >> l >> r >> k; vector < pair < long long, long long > > g; for (long long j = l; j <= r; ++ j) { marked[j] = 0; g.push_back(make_pair(-a[j], j)); } sort(g.begin(), g.end()); long long cut = r+1, ok = 1; for (long long j = 0; j < g.size() && ok; ++ j) { if(marked[j])continue; for (long long id = g[j].second+1; id < cut && ok; ++ id) { if(!marked[id] && a[id] - g[j].first <= k) { marked[id] = 1; continue; } else { //cout << a[id] << " " << g[j].first << endl; ok = 0; } } cut = g[j].second; } cout << ok << endl; } } void solve13() { long long j = 1; for (long long i = 1; i <= n; ++ i) { j = max(j, i); while(j < n && a[j] <= a[j+1])j ++; go[i] = j; } for (long long i = 1; i <= m; ++ i) { cin >> l >> r >> k; if(go[l] < r)cout << 0 << endl; else cout << 1 << endl; } } int main() { speed(); read(); if(n <= 5000)solve5000(); else solve13(); return 0; }

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

sortbooks.cpp: In function 'void solve5000()':
sortbooks.cpp:39:33: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   39 |         for (long long j = 0; j < g.size() && ok; ++ j)
      |                               ~~^~~~~~~~~~
#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...