제출 #865787

#제출 시각아이디문제언어결과실행 시간메모리
865787Nuraly_Serikbay새로운 문제 (POI11_met)C++17
컴파일 에러
0 ms0 KiB
#pragma GCC optimize("O3,unroll-loops") #pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt") #include <map> #include <set> #include <list> #include <cmath> #include <ctime> #include <deque> #include <queue> #include <stack> #include <string> #include <bitset> #include <cstdio> #include <limits> #include <vector> #include <climits> #include <cstring> #include <cstdlib> #include <fstream> #include <numeric> #include <sstream> #include <cassert> #include <iomanip> #include <iostream> #include <algorithm> #include <stdio.h> #include <fstream> #include <unordered_map> using namespace std; typedef long long ll; typedef long double ld; //#define int long long #define all(x) x.begin(),x.end() #define pb push_back #define ent "\n" const int maxn = (int)3e5 + 1; const int inf = (int)1e9; int n,m; vector<int>pos[maxn],MID[maxn]; int a[maxn]; int l[maxn],r[maxn],w[maxn]; pair<int,int>seg[maxn]; ll t[maxn * 4],q[maxn * 4]; void upd(int v,int tl,int tr,int l,int r,int x){ if(l > tr || r < tl)return; if(l <= tl && tr <= r){ t[v] += x; t[v] = min(t[v],inf); return; } int mid = (tl + tr) >> 1; upd((v << 1),tl,mid,l,r,x); upd((v << 1) + 1,mid + 1,tr,l,r,x); } ll get(int v,int tl,int tr,int pos){ if(t[v] >= inf || tl == tr){ return t[v]; } int mid = (tl + tr) >> 1; if(pos <= mid){ return (t[v] + get((v << 1), tl,mid,pos)); } else{ return (t[v] + get((v << 1) + 1,mid + 1,tr,pos)); } } int ans[maxn]; void solve(){ cin >> n >> m; for(int i = 1 ; i <= m ; i ++){ int o;cin >> o; pos[o].pb(i); } for(int i = 1 ; i <= n ; i ++){ cin >> a[i]; } int k;cin >> k; for(int i = 1 ; i <= k ; i++){ cin >> l[i] >> r[i] >> w[i]; } for(int i = 1 ; i <= n ; i ++){ seg[i] = {1, k}; } bool ok = 1; while(ok){ memset (t, 0, sizeof(t)); ok = 0; for(int i = 1 ; i <= n ; i ++){ if(seg[i].first <= seg[i].second){ int mid = (seg[i].first + seg[i].second) >> 1; MID[mid].pb(i); ok = 1; } } for(int i = 1 ; i <= k ; i ++){ if(l[i] <= r[i]){ upd(1,1,m,l[i],r[i],w[i]); } else{ upd(1,1,m,l[i],m,w[i]); upd(1,1,m,1,r[i],w[i]); } ll sum = 0; for(int x : MID[i]){ sum = 0; for(int y : pos[x]){ sum += get(1,1,m,y); if(sum >= a[x])break; } if(sum >= a[x]){ seg[x].second = i - 1; ans[x] = i; } else{ seg[x].first = i + 1; } } MID[i].clear(); } } for(int i = 1 ; i <= n ; i ++){ if (ans[i] == 0) cout << "NIE\n"; else cout << ans[i] << '\n'; } } int main(){ ios_base::sync_with_stdio(0); cin.tie(0); int t = 1; //cin >> t; while(t --){ solve(); } return 0; }

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

met.cpp: In function 'void upd(int, int, int, int, int, int)':
met.cpp:56:22: error: no matching function for call to 'min(ll&, const int&)'
   56 |   t[v] = min(t[v],inf);
      |                      ^
In file included from /usr/include/c++/10/bits/stl_tree.h:63,
                 from /usr/include/c++/10/map:60,
                 from met.cpp:4:
/usr/include/c++/10/bits/stl_algobase.h:230:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  230 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:230:5: note:   template argument deduction/substitution failed:
met.cpp:56:22: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   56 |   t[v] = min(t[v],inf);
      |                      ^
In file included from /usr/include/c++/10/bits/stl_tree.h:63,
                 from /usr/include/c++/10/map:60,
                 from met.cpp:4:
/usr/include/c++/10/bits/stl_algobase.h:278:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  278 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:278:5: note:   template argument deduction/substitution failed:
met.cpp:56:22: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   56 |   t[v] = min(t[v],inf);
      |                      ^
In file included from /usr/include/c++/10/algorithm:62,
                 from met.cpp:26:
/usr/include/c++/10/bits/stl_algo.h:3468:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(std::initializer_list<_Tp>)'
 3468 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3468:5: note:   template argument deduction/substitution failed:
met.cpp:56:22: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   56 |   t[v] = min(t[v],inf);
      |                      ^
In file included from /usr/include/c++/10/algorithm:62,
                 from met.cpp:26:
/usr/include/c++/10/bits/stl_algo.h:3474:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(std::initializer_list<_Tp>, _Compare)'
 3474 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3474:5: note:   template argument deduction/substitution failed:
met.cpp:56:22: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   56 |   t[v] = min(t[v],inf);
      |                      ^