이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
#define ll long long
namespace __gnu_pbds{
typedef tree<ll,
null_type,
less_equal<ll>,
rb_tree_tag,
tree_order_statistics_node_update> ordered_set;
}
using namespace __gnu_pbds;
#define ld long double
double eps=1e-9;
#define all(v) v.begin(),v.end()
#define fast cin.tie(0);cin.sync_with_stdio(0);
#define fs(n) fixed<<setprecision(n)
#define PI acos(-1.0)
#define inp(i,n,arr) for(int i=0;i<n;i++)cin>>arr[i];
#define clr(x,val) memset((x),(val),sizeof(x))
#define sz(x) (ll)x.size()
#define mp make_pair
#define debug(x) cout<<"[ "<<x<<" ]"<<endl;
#define debug2(x,y) cout<<"[ "<<x<<" ] "<<", [ "<<y<<" ]"<<endl;
#define debug3(x,y,z) cout<<"[ "<<x<<" ] "<<" , [ "<<y<<" ] "<<" , [ "<<z<<" ] "<<"\n";
void local(){
fast;
#ifndef ONLINE_JUDGE // ^_^
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif // ONLINE_JUDGE*/
}
int dx[] = {-1,0,1 ,0};
int dy[] = {0,-1,0 , 1};
const ll oo=(ll)8e18;
const ll mod=(ll)998244353;
//====================
void solution(){
int n,m;cin>>n>>m;
int cnt=0;
int height=0;
for(int i=0;i<n;i++){
int num;cin>>num;
if(num>height+m)
cnt++,height+=m;
else
height=num;
}
cout<<cnt;
}
int main(){
local();
int t=1,cnt=1;
// cin>>t;
while(t--){
solution();
cnt++;
}
}
컴파일 시 표준 에러 (stderr) 메시지
triusis.cpp: In function 'void local()':
triusis.cpp:30:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
30 | freopen("input.txt", "r", stdin);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
triusis.cpp:32:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
32 | freopen("output.txt", "w", stdout);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |