제출 #920376

#제출 시각아이디문제언어결과실행 시간메모리
920376hasuhasuiroAutobahn (COI21_autobahn)C++17
0 / 100
1 ms348 KiB
#include <bits/stdc++.h> using namespace std; int main() { int N, K, X; cin >> N >> K >> X; vector l(N, 0), r(N, 0), t(N, 0); for(int i = 0; i < N; i++) { cin >> l[i] >> t[i] >> r[i]; r[i]++; } vector P(0, 0); for(int i = 0; i < N; i++) { P.push_back(l[i]), P.push_back(r[i]), P.push_back(l[i]+t[i]); } int sizep(size(P)); for(int i = 0; i < sizep; i++) { P.push_back(P[i]+X), P.push_back(P[i]-X); } sort(begin(P), end(P)); P.erase(unique(begin(P), end(P)), end(P)); /* for(int i = 0; i < size(P); i++) { cout << ' ' << P[i]; } cout << endl; */ map<int, int> mp; for(int i = 0; i < size(P); i++) { mp[P[i]] = i; } vector imos(size(P), 0); for(int i = 0; i < N; i++) { imos[mp[l[i]]]++; imos[mp[r[i]]]--; } for(int i = 0; i < size(P)-1; i++) { imos[i+1] += imos[i]; } vector imos2(size(P), 0); for(int i = 0; i < N; i++) { imos2[mp[l[i]+t[i]]]++; imos2[mp[r[i]]]--; } for(int i = 0; i < size(P)-1; i++) { imos2[i+1] += imos2[i]; } for(int i = 0; i < size(P); i++) { if(imos[i] < K) { imos2[i] = 0; } } /* for(int i = 0; i < size(P); i++) { cout << ' ' << imos2[i]; } cout << endl; */ int ans(0), res(0); for(int i = 0, j = 0; i+1 < size(P); i++) { for(; j+1 < size(P); j++) { if(P[i]+X <= P[j]) break; else res += imos2[mp[P[j]]] * (P[j+1]-P[j]); } /* cout << res << ' ' << P[i] << ' ' << P[j] << endl; */ ans = max(res, ans); res -= imos2[mp[P[i]]] * (P[i+1] - P[i]); } cout << ans << endl; return 0; }

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

autobahn.cpp: In function 'int main()':
autobahn.cpp:24:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   24 |     for(int i = 0; i < size(P); i++) { mp[P[i]] = i; }
      |                    ~~^~~~~~~~~
autobahn.cpp:27:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   27 |     for(int i = 0; i < size(P)-1; i++) { imos[i+1] += imos[i]; }
      |                    ~~^~~~~~~~~~~
autobahn.cpp:31:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   31 |     for(int i = 0; i < size(P)-1; i++) { imos2[i+1] += imos2[i]; }
      |                    ~~^~~~~~~~~~~
autobahn.cpp:32:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   32 |     for(int i = 0; i < size(P); i++) { if(imos[i] < K) { imos2[i] = 0; } }
      |                    ~~^~~~~~~~~
autobahn.cpp:42:31: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   42 |     for(int i = 0, j = 0; i+1 < size(P); i++) {
      |                           ~~~~^~~~~~~~~
autobahn.cpp:43:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   43 |         for(; j+1 < size(P); j++) {
      |               ~~~~^~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...