제출 #91068

#제출 시각아이디문제언어결과실행 시간메모리
91068Aydarov03금 캐기 (IZhO14_divide)C++14
0 / 100
38 ms604 KiB
#include <bits/stdc++.h> #define int long long #define fr first #define sc second using namespace std; pair<int , pair<int,int> > p[100005]; bool used[100005]; int ans; main() { int n; cin >> n; for(int i = 1; i <= n; i++) { scanf("%d%d%d" , &p[i].fr , &p[i].sc.fr , &p[i].sc.sc); // place , gold , energy } for(int j = 1; j <= n; j++) { int start = p[j].fr , en = start + p[j].sc.sc , gold = p[j].sc.fr; for(int now = j; now <= n; now++) { bool in = false; int ls = 0 , fr; for( int i = now+1; i <= n; i++) { if( p[i].fr >= start && p[i].fr <= en ) { in = true; if( p[i].fr + p[i].sc.sc > ls ) { ls = p[i].fr + p[i].sc.sc; fr = p[i].fr; now = i; } gold += p[i].sc.fr; } else break; } if(in && ls > en) { start = fr , en = ls; now--; } else if( p[now + 1 ].fr - p[now + 1 ].sc.sc <= en ) { start = en = p[now+1].fr; gold += p[now+1].sc.fr; } } ans = max( ans , gold ); } cout << ans; }

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

divide.cpp:11:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main()
      ^
divide.cpp: In function 'int main()':
divide.cpp:18:62: warning: format '%d' expects argument of type 'int*', but argument 2 has type 'long long int*' [-Wformat=]
         scanf("%d%d%d" , &p[i].fr , &p[i].sc.fr , &p[i].sc.sc); // place , gold , energy
                                                              ^
divide.cpp:18:62: warning: format '%d' expects argument of type 'int*', but argument 3 has type 'long long int*' [-Wformat=]
divide.cpp:18:62: warning: format '%d' expects argument of type 'int*', but argument 4 has type 'long long int*' [-Wformat=]
divide.cpp:18:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d%d%d" , &p[i].fr , &p[i].sc.fr , &p[i].sc.sc); // place , gold , energy
         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
divide.cpp:33:17: warning: 'start' may be used uninitialized in this function [-Wmaybe-uninitialized]
                 if( p[i].fr >= start &&  p[i].fr <= en )
                 ^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...