제출 #1054792

#제출 시각아이디문제언어결과실행 시간메모리
1054792cpdreamerFinancial Report (JOI21_financial)C++14
5 / 100
239 ms27844 KiB
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <utility> #define V vector #define P pair #define S second #define F first #define pb push_back #define all(v) v.begin(),v.end() typedef long long ll; using namespace __gnu_pbds; using namespace std; typedef tree<int,null_type,less<int>,rb_tree_tag, tree_order_statistics_node_update> indexed_set; static int called = 0;const long long MOD = 1e9+7; // 1e9 + 7 void file(){ freopen("input.txt.txt","r",stdin); freopen("output.txt.txt","w",stdout); } void file(string s) { freopen((s + ".in").c_str(), "r", stdin); freopen((s + ".out").c_str(), "w", stdout); } struct segtree{ private: struct node{ int max; }; node single(int v){ return {v}; } node neutral={0}; node merge(node a,node b){ return {max(a.max,b.max)}; } public: int size; V<node>query; void init(int n){ size=1; while(size<n)size*=2; query.assign(2*size,neutral); } void set(int i,int v,int x,int lx,int rx){ if(rx-lx==1){ query[x]=single(v); return; } int m=(lx+rx)/2; if(i<m) set(i,v,2*x+1,lx,m); else set(i,v,2*x+2,m,rx); query[x]=merge(query[2*x+1],query[2*x+2]); } void set(int i,int v){ set(i,v,0,0,size); } node calc(int l,int r,int x,int lx,int rx){ if(lx>=r || rx<=l) return neutral; if(l<=lx && rx<=r) return query[x]; int m=(lx+rx)/2; node a=calc(l,r,2*x+1,lx,m); node b=calc(l,r,2*x+2,m,rx); return merge(a,b); } node calc(int l,int r){ return calc(l,r,0,0,size); } }; void solve() { int n; int d; cin>>n>>d; int A[n]; for(int i=0;i<n;i++) cin>>A[i]; V<int>vp; for(int i=0;i<n;i++) vp.pb(A[i]); sort(all(vp)); auto it=unique(all(vp)); vp.resize(distance(vp.begin(),it)); map<int,int>mp; for(int i=0;i<vp.size();i++) mp[vp[i]]=i; for(int i=0;i<n;i++) A[i]=mp[A[i]]; int ans=1; segtree tree; tree.init(1e6); tree.set(A[0],1); for(int i=1;i<n;i++){ int curr=tree.calc(0,A[i]).max+1; ans=max(ans,curr); tree.set(A[i],curr); } cout<<ans<<endl; } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); //file(); solve(); return 0; }

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

Main.cpp: In function 'void solve()':
Main.cpp:88:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   88 |     for(int i=0;i<vp.size();i++)
      |                 ~^~~~~~~~~~
Main.cpp: In function 'void file()':
Main.cpp:18:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   18 |     freopen("input.txt.txt","r",stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:19:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   19 |     freopen("output.txt.txt","w",stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp: In function 'void file(std::string)':
Main.cpp:22:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   22 |     freopen((s + ".in").c_str(), "r", stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:23:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   23 |     freopen((s + ".out").c_str(), "w", stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp: At global scope:
Main.cpp:15:12: warning: 'called' defined but not used [-Wunused-variable]
   15 | static int called = 0;const long long MOD = 1e9+7; // 1e9 + 7
      |            ^~~~~~
#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...