Alex_tz307

Classic - Level 3

Oct 30th, 2020
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.75 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. #define int long long
  3.  
  4. using namespace std;
  5.  
  6. ifstream fin("text.in");
  7. ofstream fout("text.out");
  8.  
  9. int32_t main() {
  10.     fin.sync_with_stdio(false);
  11.     fout.sync_with_stdio(false);
  12.     fin.tie(nullptr);
  13.     fout.tie(nullptr);
  14.     int N;
  15.     fin >> N;
  16.     vector < int > a(N + 1);
  17.     for(int i = 1; i <= N; ++i)
  18.         fin >> a[i];
  19.     int M;
  20.     fin >> M;
  21.     fout << M << '\n';
  22.     while(M--) {
  23.         int id, power, st, dr;
  24.         fin >> id >> power >> st >> dr;
  25.         int mn = INT_MAX, ans = -1;
  26.         for(int i = st + 1; i <= dr + 1; ++i)
  27.             if(a[i] < mn) {
  28.                 mn = a[i];
  29.                 ans = i;
  30.             }
  31.         fout << id << ' ' << ans - 1 << ' ' << power << '\n';
  32.     }
  33. }
  34.  
Add Comment
Please, Sign In to add comment