ログイン
新規登録
AtsuoCoder Petrozavodsk Contest 001
読込中…
Home
Tasks
Clar
Submissions
Standings
提出 6cac6cee-b63b-4085-a26b-ddcf30197da9
コード
#include <iostream> // cout, endl, cin #include <string> // string, to_string, stoi #include <vector> // vector #include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound #include <utility> // pair, make_pair #include <tuple> // tuple, make_tuple #include <cstdint> // int64_t, int*_t #include <cstdio> // printf #include <map> // map #include <queue> // queue, priority_queue #include <set> // set #include <stack> // stack #include <deque> // deque #include <unordered_map> // unordered_map #include <unordered_set> // unordered_set #include <bitset> // bitset #include <cctype> // isupper, islower, isdigit, toupper, tolower #include <cmath> // pow, sqrt #include <iomanip> // setprecision #define int int64_t #define double long double using namespace std; signed main() { //cout << fixed << setprecision(10); int n, m; cin >> n >> m; vector<int> food(m + 1, 0); vector<int> nutrient(m + 1, 0); vector<int> type(m + 1, 0); set<int> ate; int now = 0; for (int i = 1; i <= m; i++) { cin >> food.at(i); if (!ate.count(food.at(i))) { now++; ate.insert(food.at(i)); } type.at(i) = now; } for (int i = 1; i <= m; i++) cin >> nutrient.at(i); int minimum = -1, l = 0, r = 0; if (ate.size() < n) { cout << -1 << " " << -1 << endl; return 0; } for (int i = 1; i < m; i++) { for (int j = i + 1; j <= m; j++) { if (type.at(j) - type.at(i - 1) < n) continue; if (minimum == -1) minimum = nutrient.at(j) - nutrient.at(i); else minimum = min(minimum, nutrient.at(j) - nutrient.at(i)); l = i; r = j + 1; break; } } cout << l << " " << r << endl; }
結果
問題
点数
言語
結果
実行時間
メモリ
F - Sliding
0
C++
TLE
2104 ms
20676 KiB